Behavior-Driven Development (BDD) With TestComplete

Applies to TestComplete 15.47, last modified on January 20, 2023

About

Behavior-driven development (BDD) is a software development methodology that combines technical aspects and business interests. It implies that the team decides what to test and to what extent, and creates test scenarios in a simple language (like Gherkin) that is understandable by even non-technical-savvy employees.

In TestComplete, you can create such BDD tests against desktop, web and mobile applications, you can also automate their test steps and run these tests daily.

Scenarios

To create and run BDD tests in TestComplete, you use the Scenarios project item. It contains child items (called features) that correspond to .feature files or feature descriptions used by such tools as CucumberStudio or Cucumber:

BDD scenarios in TestComplete

Click the image to enlarge it.

In TestComplete, you can write scenarios anew, import them from CucumberStudio, or load from feature files on your hard drive.

Scenarios are written in Gherkin – a special language that is used for creating BDD tests. TestComplete supports both English and native-language Gherkin keywords.

Workflow

BDD scenarios describe test cases in a plain-text form, and though they use Gherkin keywords, they can be  created by non-technical-savvy employees. Quite often, they are written by product managers or subject matter experts, and are automated by the QA team or special automation engineers.

The latter can import scenarios to TestComplete and automate the scenarios’ test steps. After that, they can include BDD scenarios in automated tests that run on a daily basis.

BDD workflow

How automation works

  • After you create a feature file or import it to TestComplete, click Generate Step Definitions to command TestComplete to create script functions that will implement a step. You will then see the created code in the script editor. For instance, here is how the steps look like in JavaScript:

    Generated script functions

    Click the image to enlarge it.

    You can also create script code for BDD tests in Python, VBScript, JavaScript, C++Script and C#Script. DelphiScript is not supported.

  • As you can see, for each function, TestComplete also generates an expression that links a function to a test step:

    A binding expression

    When you run a scenario, TestComplete will run the script functions that match the test steps of this scenario.

    For more information on the syntax of these expressions, see Binding Script Functions to Test Steps.

  • After you generate script functions for test steps, you can create function bodies. You can either write script code manually, or record a script. See Create Test Step Scripts.

  • After you create script code, you can run your BDD scenarios. The easiest way to do this is to right-click a scenario in the Gherkin editor and to select Run This Scenario from the context menu:

    Run BDD tests from Gherkin editor

    You can also run BDD tests as test items of your project, from scripts and from the command line. See Run BDD Tests. In other words, you can easily include BDD tests in your automated test set and run them on a regular basis.

  • Tip: It is considered to be a good approach to assign tags to feature files and individual scenarios in them, and then run BDD tests by tags. See Tags for complete information on this.

CucumberStudio integration

In TestComplete, you can create BDD scenarios anew in the Gherkin editor, import them from a feature file on your hard drive, or import them from CucumberStudio. CucumberStudio (formerly known as HipTest) is a cloud-based test platform by SmartBear for Agile testing and behavior-driven development. It’s a feature-rich solution that enables you to create BDD scenarios quickly and easily, maintain these scenarios and run them.

TestComplete tightly integrates with CucumberStudio. Your team can continue using CucumberStudio to create and update BDD scenarios, and use TestComplete to automate and run these scenarios. This approach helps you save time and resources needed to run tests and work more on test automation, increasing the number of automated tests and test coverage.

For complete information on CucumberStudio support in TestComplete, see CucumberStudio Integration.

Sample project to explore

TestComplete includes a sample BDD test project that contains a few scenarios and scripts that automate the test steps. To open the project, simply select Samples > BDD on the TestComplete start page:

Open the BDD sample project from the Start page

Click the image to enlarge it.

You can also open the project file from your hard drive: <TestComplete 15 Samples>\BDD\WebStore_BDDSample.pjs.

Further reading

Video

To learn more about integrating TestComplete tests into your development, testing, and release workflow, you can take a video course in our SmartBear Academy:

smartbear.com/academy/testcomplete/testcomplete-qa-architect

See Also

TestComplete 15 Documentation

Highlight search results