BDD is useful for ensuring that your automation focuses on business needs while meeting all user requirements. It can also help business stakeholders to understand automated tests at a high level without going into technical detail.

Using these APIs, you can group together Test Steps based on their behavior to define pre-conditions, actions and checks respectively.

BDD APIs

Provar provides BDD APIs for Given, When and Then. As of Provar version 1.8.11, And and But are also supported.

Given API

The purpose of Given in BDD is to put your system in a ready state before an interaction or action.

In Provar, the Given API is used to group the Test Steps in your Test Case which define a set of pre-conditions or data setup. For example, ‘User is on the Contact New Screen’:

When API

The purpose of When in BDD is to describe the key actions that a user performs after the preconditions are met.

In Provar, the When API is used to group the Test Steps in your Test Case which perform the actions. For example, ‘User completes the form and clicks Save’:

Then API

The purpose of Then in BDD is to observe the outcomes of the interaction performed by the user.

In Provar the Then API is used to group the Test Steps in your Test Case which carry the result assertions. For example, ‘Assert that a contact is created and the user is redirected to the contact view screen’.

And API

The purpose of And in BDD is to combine two or more same type of action. And can be used with GIVEN, WHEN, THEN.

But API

The purpose of But in BDD is to create a condition statement. But can be used with GIVEN, WHEN, THEN.

BDD Reporting

As of Provar Version 1.8.11, you can use Provar’s BDD Reporting feature to report on BDD Test Steps only.

To use this feature, open the Export Test Run dialog then select the ‘Only BDD’ checkbox:

Click ‘Finish’.

The Test Report will be generated with only the BDD Test Steps showing:

Variable Values in BDD Reports

When a BDD test step is created with a variable, e.g. {NOW}, this variable will be resolved during the execution so that the actual value is shown in the Test Runner and in reporting.

In Test Runner:

In reporting:

Only BDD Reporting now includes Sub-Step Screenshots

From version 1.9, if you generate a report using the “Only BDD” option, Provar will include in the report any screenshots captured by test steps that are sub-steps of a BDD step, even if the test step themselves are not visible in the report.

For example, this test step includes screenshots and is a sub-step under a “Given” test step:

When a “Only BDD” report is generated, the test step itself is hidden but its screenshots are displayed against the Given test step:

This means that the screenshots of many sub-steps may be included against the same BDD test step, as shown above.