Interface IPerformance
- Namespace
- CSF.Screenplay
- Assembly
- CSF.Screenplay.Abstractions.dll
A Performance corresponds to a self-contained scope of Performables, performed by Actors, which results in success or failure.
public interface IPerformance : IHasPerformanceIdentity, IHasServiceProvider, IDisposable, IBeginsAndEndsPerformance
- Inherited Members
Remarks
In 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 a performance object, deriving from this interface, often corresponds to a .NET method in some manner. The method might be regular application logic or it might be a Test/Scenario, using the semantics of an applicable testing framework. The performance object (deriving from this interface) provides a name for the method (the performance name) as well as tracking its running-state. When using BDD-style testing frameworks, there might be a single .NET method to which the performance is linked. Nevertheless, a performance defines an execution scope (with a beginning and end). Even if that scope does not correspond neatly to a single method, it exists regardless.
The body of a performance method typically creates one or more Actor via the IStage and then has the actor execute one or more performables. Particularly when using Screenplay for automated testing, these performables are organised into a beginning, middle and end, corresponding to the "Given, When, Then" design popular in testing. These three phases are included for use in Screenplay, declared in PerformancePhase. The use of performance phases is optional, although encouraged.
Every performance method should return a result, indicating whether the performance was a success. A successful performance is one which progressed from beginning to end, and every step (performable) operated in the manner in which was expected. Additionally, when using Screenplay for software testing, a performance is a success if all its _assertions_ pass. A succesful performance should return true from its performance method. An unsuccessful one should return false.
As noted above, when Screenplay is being used for automated testing, the performance method corresponds directly 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.
The object which implements this interface is the representation of the the method described above. One instance of this type - "the performance object" - corresponds to one execution of such a method. The performance object also corresponds to the lifetime of a 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.
IReadOnlyList<IdentifierAndName> NamingHierarchy { get; }
Property Value
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.
PerformanceState
Gets a value which indicates the state of the current performance.
PerformanceState PerformanceState { get; }
Property Value
- See Also