Skip to content

Implementation of the Screenplay pattern (aka Journey) for BDD acceptance tests

License

Notifications You must be signed in to change notification settings

csf-dev/CSF.Screenplay

Repository files navigation

CSF.Screenplay

Screenplay is a design pattern for writing BDD tests; it has formerly been known as the Journey pattern. Screenplay helps developers write high-value test logic:

  • It encourages human-readable test code
  • Screenplay follows the SOLID design principles, aiding reusability
  • Screenplay keeps tests focussed upon actors how they use the software under test
  • Detailled human-readable reports are produced at the end of every test run
  • It is an ideal framework for controlling technologies such as Selenium Web Driver

The CSF.Screenplay library is inspired by Serenity, a testing framework which includes a Java implementation of the Screenplay pattern. It is available for download via NuGet.

Getting started

There is a documentation wiki available with a wealth of learning materials. To demonstrate the basics though, here is an example test.

This example is written using NUnit; it is a concise and widely recognised test format. For a better BDD experience, we recommend using the SpecFlow test framework.

[TestFixture]
[Description("Users should be able to buy groceries via the application")]
public class UsersCanBuyGroceries
{
  [Test,Screenplay]
  [Description("Joe should see a thankyou message when he uses the application to buy eggs.")]
  public void JoeShouldSeeAThankyouMessageWhenHeBuysEggs(ICast cast)
  {
    var joe = cast.Get<Joe>();

    Given(joe).WasAbleTo(SearchTheShop.ForGroceries());
    When(joe).AttemptsTo(Click.On(GroceriesForSale.BuyEggsButton));
    var message = Then(joe).ShouldSee(TheText.Of(GroceriesForSale.FeedbackMessage));

    Assert.That(message, Is.EqualTo("Thankyou for buying eggs."));
  }
}

Continuous integration status

CI builds are configured via both Travis (for build & test on Linux/Mono) and AppVeyor (Windows/.NET). Below are links to the most recent build statuses for these two CI platforms.

Platform Status
Linux/Mono (Travis) Travis Status
Windows/.NET (AppVeyor) AppVeyor status