ConditionBaseAttribute Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This attribute is used to conditionally control whether a test class or a test method will run or be ignored, based on a condition and using an optional message.
[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
- Inheritance
-
ConditionBaseAttribute
- Derived
- Attributes
Remarks
This attribute isn't inherited. Applying it to a base class will not affect derived classes.
Whether the same condition attribute type can be applied more than once to a single test class or test method is decided by each derived attribute through its own AllowMultiple value:
- MemberConditionAttribute and ExecutableConditionAttribute set AllowMultiple to
true. Stacked usages with distinct GroupName values are combined with a logical AND, while repeated usages that produce the same GroupName are combined with a logical OR. - OSConditionAttribute, CIConditionAttribute and
ArchitectureConditionAttributeset AllowMultiple tofalse: stacking them is a compile-time error. OSConditionAttribute andArchitectureConditionAttributetake a flags enum, so combine the values with the bitwise OR operator instead, for example[OSCondition(OperatingSystems.Windows | OperatingSystems.Linux)]. There is nothing to combine for CIConditionAttribute, which only carries a ConditionMode.
Condition attributes are grouped by their GroupName value, regardless of attribute type. Values within the same group are combined with a logical OR, and different groups are combined with a logical AND. The built-in condition attribute types use distinct group names for different condition kinds, so combining those different built-in kinds requires all of them to be satisfied.
Constructors
| Name | Description |
|---|---|
| ConditionBaseAttribute(ConditionMode) |
Initializes a new instance of the ConditionBaseAttribute class. |
Properties
| Name | Description |
|---|---|
| GroupName |
Gets the group name for this attribute. This is relevant when multiple attributes that inherit ConditionBaseAttribute are present. The IsConditionMet values of attributes in the same group are "OR"ed together. While the value from different groups is "AND"ed together. In other words, a test will be ignored if any group has all its IsConditionMet values as false. |
| IgnoreMessage |
Gets or sets the ignore message indicating the reason for ignoring the test method or test class. |
| IsConditionMet |
Gets a value indicating whether the condition is met. The implementation of this property shouldn't read the Mode property. |
| Mode |
Gets the condition mode. |
| ShouldRun |
Gets a value indicating whether the test method or test class should be ignored. |