This is the manual for an older version of Storyplayer.

Test Setup / Teardown Phases

Repeatable testing is all about making sure that your test runs under the same conditions each and every time. The only variable in your testing should be the software under test. Once your test environment has been created, Storyplayer supports automated setup and teardown of your test conditions, to make your tests as repeatable as possible.

These phases are optional.

Running Order

Test conditions are created after the test environment has been created, and they are reverted just before the test environment is destroyed:

  1. Test Environment Setup
  2. Test Setup
  3. Pre-test Prediction
  4. Pre-test Inspection
  5. Action
  6. Post-test Inspection
  7. Test Teardown
  8. Test Environment Teardown

Setting Up Your Test Conditions

To setup your test conditions, add a TestSetup() function to your story:

$story->addTestSetup(function(StoryTeller $st) {
	// steps go here
});

Reverting Your Test Conditions

Once your test has finished, add a TestTeardown() function to put your test environment back to how it was before your TestSetup() function ran:

$story->addTestTeardown(function(StoryTeller $st) {
	// steps go here
});

Templating Your Test Conditions

On larger applications, you’ll normally end up grouping stories together because they are testing similiar aspects of your app. You might find that all the stories inside a group can share the same test conditions. You can use Storyplayer’s story templating to share the same TestSetup() and TestTeardown() methods across multiple stories.