Software tests are written as sequences of steps that do things and then check the results of what’s been done. Complete test suites--sets of test cases that fully cover normal, alternate, and exception scenarios--include many variations on a basic scenario. To produce good, complete tests, a tester needs to have a consistent format for writing tests that includes a mechanism for identifying the points where variations can occur.

One authoring style that's gaining in popularity is known by names such as "behavior-driven development" (BDD), “test-driven development” (TDD), or "acceptance-test driven development" (ATDD). Regardless of what the format is called, tests are written as sequences of preconditions, actions, and results. A language called Gherkin (sometimes referred to as "Cucumber") can be used for writing the details of individual scenarios. Gherkin scenarios are divided into sequences of Given, When, and Then sections. Here's an example for just one step in adding a new expense report, specifically the step on which the user enters a date and a number of miles driven:

preconditions

Given

a logged in manager is on the Create New Project page

inputs and actions

When

the manager enters a good project name

and the manager enters a non-blank description

and the manager clicks the Create New Project button

expected results

Then

the new project is created

and the manager is returned to his My Projects page

and the new project appears on the My Projects page

The advantage of the BDD approach is that it can normalize the steps in the activity; specifically,

Applying this to the original procedure results in a more regular and a more detailed test:

  1. Open a web browser to the TAME home page..

Given the manager wants to add a new project to TAME

When the manager opens a web browser to the TAME homepage

Then the TAME homepage is displayed.

  1. Click the Log in link to bring up the Log in page.

Given the manager is on the TAME homepage

When the manager clicks the Log in link

Then the Log in page is displayed

  1. On the Log in page enter a good manager's user ID and password, then click the Log in button.

Given the manager is on the Log in page

And no one is currently logged in

When the manager enters his user ID

And the manager enters his correct password

And the manager clicks "Log in"

Then the manager is taken to his My Projects page

And the page displays all of the projects the manager manages

And the page displays all of the projects the manager belongs to but does not manage

  1. Verify that you're now on the My Projects page.
  1. Verify that the My Projects page shows the manager's current projects, both those that he manages and others to which he merely belongs.
  1. Click the "Create a New Project" link.

Given a manager is on his My Projects page

When the manager clicks the Create a New Project link

Then the manager is taken to the New Project page.

  1. Enter a name and description, then click "Create New Project."

Given a logged in manager is on the Create New Project page

When the manager enters a good project name

And the manager enters a non-blank description

And the manager clicks the Create New Project button

Then the new project is created

And the manager is returned to his My Projects page

And the new project appears on the My Projects page

  1. Verify that the new project appears on the "My Projects" page.
  1. Click the Log out button to return to the TAME home page.

Given a logged in manager is on his My Projects page

When the manager clicks the Log Out button

Then the manager is returned to the TAME homepage

And the manager is logged out

  1. Verify that the manager is logged out.