Table of Contents

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
TestActionAttribute
ScreenplayAssemblyAttribute
Implements
ITestAction
Inherited Members

Examples

Decorate your assembly with this attribute using the syntax [assembly: CSF.Screenplay.ScreenplayAssembly(typeof(MyScreenplayFactory))]. 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.

There is a further example available in the getting started guide for Screenplay and NUnit3.

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. Its purpose is to signpost the Screenplay Factory (see below) to the NUnit/Screenplay integration.

This attribute has one mandatory parameter; that is the Type of the Screenplay Factory which should be used in this test project. A Screenplay Factory is a class which provides a concrete implementation of IGetsScreenplay. An instance of the factory 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 in the project must additionally be decorated with the ScreenplayAttribute in order to activate the Screenplay architecture for that test. It is possible to mix & match Screenplay-based and non-Screenplay-based tests within a single test project.

All Screenplay-based tests within a test project/assembly will use the Screenplay Factory which is identified by this attribute.

Constructors

ScreenplayAssemblyAttribute(Type)

Initializes a new instance of ScreenplayAssemblyAttribute.

public ScreenplayAssemblyAttribute(Type factoryType)

Parameters

factoryType Type

The concrete type of a class which implements IGetsScreenplay.

Remarks

The factoryType specified in this constructor must meet all of the following criteria:

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 ITest

The test that has just been run.

BeforeTest(ITest)

Executed before each test is run

public override void BeforeTest(ITest test)

Parameters

test ITest

The 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-null Screenplay instance.

See Also