The business layer

The business layer is the set of resources that define the behaviors to be tested. The fundamental building blocks of this layer are the scenarios. A scenario is a description of user or system behavior that can be tested. Scenarios are written in the Gherkin language. They typically have three sections:

  • The Given section defines pre-conditions.
  • The When section defines the actions to test.
  • The Then section defines the expected outcome.

The following is an example of a test written in Gherkin.

Scenario: Set a user's email address
    Given I am a user with the "Underwriting Supervisor" role
    When I set my email address to "ssmith@customer.com"
    Then my primary email address should be "ssmith@customer.com"

Other than the scenario name, every line in a scenario is referred to as a step. A step is a reusable description of one of the following:

  • A pre-condition that describes the environment (stated as a Given), or
  • An action to test within that environment (stated as a When), or
  • An expected outcome of the action (stated as a Then).

Any given step can be used in multiple scenarios. This gives you the ability to use the same natural language description in multiple scenarios, even if the underlying implementations must be different.

Every step maps to a step method. A step method is a method that locates and executes the correct implementation code for the associated scenario steps.

Scenarios are typically grouped together into features. A feature is a Cucumber file that contains a set of related scenarios. Features typically contain scenarios for a single type of user that test a single aspect of application behavior. Features can also contain a Background, which is a set of pre-condition steps that apply to all scenarios in the feature. The same step method can be used in multiple scenarios, even when those scenarios are in different features.

Note: The remainder of this documentation refers to Cucumber features as "feature files". This is to prevent confusion with the more common use of the term "feature" to refer to application behavior, such as the "assignment feature".

Scenarios can be executed individually from Studio. Scenarios can also be grouped and run together using a testing suite. For more information on executing scenarios, see Running scenarios.

The following diagram depicts an example of resources in the business layer. Specifically, this example is three separate feature files that all use the same step method: Given I am a user with the "X" role. All three step methods point to a single resource in the mapping layer.


The three layers of resources used by Behavior Testing Framework. This includes examples of resources in the business layer.

For more information on writing scenarios and creating feature files, see Writing scenarios.