Table of Contents

Class ScreenplayAttribute

Namespace
CSF.Screenplay
Assembly
CSF.Screenplay.NUnit.dll

Applied to a test method, indicates that decorated test is a Screenplay test.

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class ScreenplayAttribute : Attribute, ITestAction, ITestBuilder
Inheritance
ScreenplayAttribute
Implements
ITestAction
ITestBuilder
Inherited Members

Remarks

When a test method is decorated with this attribute then the test corresponding to that method will be executed via Screenplay. This means that the affected test method will be executed as an IPerformance. It also means that all parameters for the method will be provided by resolving them from the current performance's ServiceProvider. See the article on dependency injection in Screenplay for more information about what may be injected into test logic from DI, via the test method parameters.

Remember that for this attribute to be effective, the Assembly which contains the test method must be decorated with ScreenplayAssemblyAttribute. If it is not, then the test will fail with an exception.

Properties

Targets

Gets the targets for the attribute (when performing before/after test actions).

public ActionTargets Targets { get; }

Property Value

ActionTargets

The targets.

Methods

AfterTest(ITest)

Executed after each test is run

public void AfterTest(ITest test)

Parameters

test ITest

The test that has just been run.

BeforeTest(ITest)

Executed before each test is run

public void BeforeTest(ITest test)

Parameters

test ITest

The test that is going to be run.

BuildFrom(IMethodInfo, Test)

Build one or more TestMethods from the provided MethodInfo.

public IEnumerable<TestMethod> BuildFrom(IMethodInfo method, Test suite)

Parameters

method IMethodInfo

The method to be used as a test

suite Test

The TestSuite to which the method will be added

Returns

IEnumerable<TestMethod>

A TestMethod object

See Also