Skip to content

ScreenplayInTheTestingStack

Craig Fowler edited this page Mar 18, 2019 · 7 revisions

The core logic of Screenplay is developed independently of any testing frameworks. Integration is performed by small framework-specific plugin libraries. Following is a diagram showing Screenplay's place in the architecture of a test.

Architecture diagram showing Screenplay in the testing stack

Beginning from the test framework at the top, developers write test scenarios/cases as normal. The screenplay integration allows injection of Screenplay objects into those scenarios. These objects facilitate the execution of tasks - reusable pieces of high-level logic, written by the test developer. Through composition, high-level tasks execute lower-level tasks. The lowest-level, most granular Screenplay operations are actions and questions, of which there are many built-into Screenplay. Actions and questions interact with the software under test.

Test frameworks

There are currently two test framework integration plugins available: NUnit & SpecFlow. There is documentation available for writing new test framework plugins if they are needed.

If you develop a plugin for a testing framework then you are encouraged to share it so that other developers may use the integration you have created.

NUnit

In an NUnit-based test, the test method will contain and execute a series of Screenplay tasks. In the assert/"then" part of your test, those tasks should return result values. Those result values should be used with normal NUnit assertions in the test method.

SpecFlow

With a SpecFlow test, each SpecFlow step binding will typically execute a single Screenplay task. When using Screenplay and SpecFlow together, it's normal for your high-level tasks and your bindings to maintain a (mostly) one-to-one relationship.

As with NUnit above, assertions should not be written into the Screenplay tasks. Instead perform assertions in the "then" binding, using the result value from a task.

Clone this wiki locally