Class ScreenplayAssemblyAttribute
- Namespace
- CSF.Screenplay
- Assembly
- CSF.Screenplay.NUnit.dll
An attribute used to mark an assembly which contains Screenplay-based tests.
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class ScreenplayAssemblyAttribute : TestActionAttribute, ITestAction
- Inheritance
-
TestActionAttributeScreenplayAssemblyAttribute
- Implements
-
ITestAction
- Inherited Members
Examples
Decorate your assembly with this attribute using the syntax [assembly: CSF.Screenplay.ScreenplayAssembly]
. You may place this
into any source file, outside of any type declaration. By convention it would be put into a dedicated source file
within the Properties
project directory.
Remarks
This attribute is the core of the NUnit3 test framework integration with Screenplay. In order to run tests with Screenplay, the assembly must be decorated with this attribute.
This attribute has one mandatory parameter; that is the Type of a concrete implementation of IGetsScreenplay. That type will be instantiated by the NUnit3 integration and will be used to build and retrieve the Screenplay instance for running the Screenplay-based tests within the decorated assembly. Each test method must additionally be decorated with the ScreenplayAttribute in order to make it a Screenplay-based test.
Constructors
ScreenplayAssemblyAttribute(Type)
Initializes a new instance of ScreenplayAssemblyAttribute.
public ScreenplayAssemblyAttribute(Type factoryType)
Parameters
factoryType
TypeThe concrete type of a class which implements IGetsScreenplay.
Remarks
The factoryType
specified in this constructor must meet all of the following criteria:
- It must be a non-nullType which derives from IGetsScreenplay
- It must have a public parameterless constructor
- It must return a non-null instance of Screenplay from its GetScreenplay() method
Properties
Targets
Provides the target for the action attribute
public override ActionTargets Targets { get; }
Property Value
- ActionTargets
Methods
AfterTest(ITest)
Executed after each test is run
public override void AfterTest(ITest test)
Parameters
test
ITestThe test that has just been run.
BeforeTest(ITest)
Executed before each test is run
public override void BeforeTest(ITest test)
Parameters
test
ITestThe test that is going to be run.
GetScreenplay()
Gets the Screenplay which is to be used for tests contained in the current assembly.
public Screenplay GetScreenplay()
Returns
- Screenplay
The Screenplay.
Exceptions
- InvalidOperationException
If the Screenplay factory used with the constructor to this attribute is invalid or fails to return a non-nullScreenplay instance.