Using Screenplay standalone
Screenplay is often used as a tool for automating software tests, but it is not limited to only this usage.
Screenplay may be added to any application or library, via dependency injection.
This is as simple as installing the CSF.Screenplay NuGet package and adding Screenplay to your service collection.
For more information, see the documentation for ScreenplayServiceCollectionExtensions
.
using CSF.Screenplay;
// IServiceCollection services;
services.AddScreenplay();
// ... then, after the service collection is built:
// IServiceProvider serviceProvider;
var screenplay = serviceProvider.GetService<Screenplay>();
// Or you may constructor-inject an instance of Screenplay into
// any type which was resolved from the service provider
Once Screenplay has been added to your DI, you may resolve and use Screenplay-related services from dependency injection.
To execute some logic in the scope of a Performance
, consider using the method Screenplay.ExecuteAsPerformanceAsync
.
Abstractions package
If your solution is separated into multiple projects/assemblies then only your entry-point project needs the full CSF.Screenplay NuGet package. Once Screenplay has been added to DI, other projects in the solution may consume its logic, only requiring the CSF.Screenplay.Abstractions package.