语言

ConditionBaseAttribute 类

定义

此属性用于根据条件和使用可选消息,有条件地控制测试类还是测试方法将运行或忽略。

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, Inherited=false)]
public abstract class ConditionBaseAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, Inherited=false)]
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class ConditionBaseAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, Inherited=false)>]
type ConditionBaseAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Method, Inherited=false)>]
[<System.Runtime.CompilerServices.Nullable(0)>]
type ConditionBaseAttribute = class
    inherit Attribute
Public MustInherit Class ConditionBaseAttribute
Inherits Attribute
继承
ConditionBaseAttribute
派生
属性

注解

此属性不会继承。 将其应用于基类不会影响派生类。

同一条件属性类型是否可以多次应用于单个测试类,还是测试方法由每个派生属性通过自己的 AllowMultiple 值决定:

无论属性类型如何,条件属性都按其 GroupName 值分组。 同一组中的值与逻辑 OR 组合,不同的组与逻辑 AND 组合在一起。 内置条件属性类型对不同的条件类型使用不同的组名称,因此组合这些不同的内置类型需要满足所有这些类型。

构造函数

名称 说明
ConditionBaseAttribute(ConditionMode)

初始化 ConditionBaseAttribute 类的新实例。

属性

名称 说明
GroupName

获取此属性的组名称。 当存在多个继承 ConditionBaseAttribute 属性时,这一点相关。 IsConditionMet同一组中属性值是“OR”在一起的。 不同组的值是“AND”一起。 换句话说,如果任何组的所有 IsConditionMet 值都为 false,将忽略测试。

IgnoreMessage

获取或设置忽略消息,该消息指示忽略测试方法或测试类的原因。

IsConditionMet

获取一个值,该值指示是否满足条件。 此属性的实现不应读取该 Mode 属性。

Mode

获取条件模式。

ShouldRun

获取一个值,该值指示是否应忽略测试方法或测试类。

适用于