Carna

Context Attribute

This attribute specifies a class as a context fixture.

Carna does not search a class (not a nested class) specified by this attribute as a fixture to be run. It can be searched when the member (property or field) is defined using its type.

The available properties are as follows.

Property Description
Description Specifies a description of a fixture.
Fixtures Specifies types of fixtures that are contained by a fixture.
Tag Specifies a tag to filter a fixture.
Benefit Specifies a benefit about a fixture.
Role Specifies a role about a fixture.
Feature Specifies a feature about a fixture.
CanRunParallel Specifies a value that indicates whether child fixtures can be run in parallel. The default value is false.
IsRootFixture Specifies a value that indicates whether this fixture is searched as a fixture to be run. The default value is false.
RequiresSta Specifies a value that indicates whether to run this fixture in a single thread apartment. The default value is false.

For example:

[Specification("Stack specification")]
class StackSpec
{
    [Context("When a Stack is full")]
    class StackIsFull
    {
        ...
    }
}
[Specification("Stack specification")]
class StackSpec
{
    [Context]
    StackIsFull Context01 { get; } = default!;    
}

[Context("When a Stack is full")]
class StackIsFull
{
    ...
}
[Specification(
    "Stack specification",
    typeof(StackIsFull)
)]
class StackSpec;

[Context("When a Stack is full")]
class StackIsFull
{
    ...
}