Table of Contents

Interface IPerformance

Namespace
CSF.Screenplay
Assembly
CSF.Screenplay.Abstractions.dll

A performance represents a self-contained scope of performables which typically results in overall success or failure.

public interface IPerformance : IHasPerformanceIdentity, IHasServiceProvider, IDisposable, IBeginsAndEndsPerformance
Inherited Members

Remarks

In .NET code which uses Screenplay, a performance is .NET logic involving one or more Actor instances, executing one or more performable items. A Screenplay will be comprised of one or more performances. In practice this means that a performance is a method which would match the delegate Func<IServiceProvider, CancellationToken, Task<bool?>>, such as the following.

public Task<bool?> SamplePerformance(IServiceProvider services, CancellationToken cancellationToken)
{
  // Performance logic goes here ...
}

The performance method is comprised of a series of of performables, performed by one or more actors. Particularly when using Screenplay for automated testing, these performables are organised into a beginning, middle and end, corresponding with the phases declared in PerformancePhase. A performance should complete in either success or failure, as indicated by a true or false return value.

Where Screenplay is being used for automated testing, a performance corresponds to a single test. In the testing framework that might be called a "scenario", a "test", a "test case", or a "theory". When using Screenplay within a testing integration, the performance corresponds very closely to the current Scenario.

This interface is the representation of the scope of such a performance method in the Screenplay architecture. One instance of an object implementing this interface - "the performance object" - corresponds to one execution of such a method. The performance object also corresponds to the lifetime of the dependency injection scope; a new scope is created for each performance. Within a DI scope, the performance object is an injectable service. You may wish to read a diagram showing how screenplays, performances, actors and performables relate to one another.

Properties

NamingHierarchy

Gets an ordered list of identifiers which indicate the current performance's name within an organisational hierarchy.

List<IdentifierAndName> NamingHierarchy { get; }

Property Value

List<IdentifierAndName>

Examples

If the current performance is to be named Joe can take out the Trash, and it is part of a parent name, named Joe can do his chores then the first identifier in the list will be named Joe can do his chores and the second will be named Joe can take out the Trash.

Remarks

A Screenplay typically contains more than one performance and may contain many. It is normal to organise performances into a hierarchical structure based upon their purpose, role or relationship. The position of the current performance in that naming structure is represented by the value of this property.

The ordered list of IdentifierAndName instances indicate a path from the 'root' of the hierarchy (which has no inherent name) to the current performance. Identifier/name pairs which are earlier in the collection are considered to be closer to the root, whereas latter identifier/names are branch & leaf names. In this manner, they work very similarly to .NET namespaces. The earlier in the list that a name appears, the more general it should be, representing a wider category.

When using Screenplay with Integration, this hierarchy of names would typically correspond to the naming convention used by the testing framework. That might be based upon .NET namespaces, classes and test methods for a more traditional unit testing framework. Alternatively, for a BDD-style testing framework, it could be named based upon human-readable feature & scenario names.

Ideally this property would be immutable after a Performance is created. Unfortunately, some testing frameworks do not expose relevant naming information about a test until after the point of execution where the Performance must be created. Thus, this property is mutable, so that it is possible to 'backfill' missing naming information after the performance has been created. Wherever possible, it is recommended to avoid updating this list of identifier/names and to only set them up when creating the performance, via ICreatesPerformance.

PerformanceState

Gets a value which indicates the state of the current performance.

PerformanceState PerformanceState { get; }

Property Value

PerformanceState
See Also