Backgrounds and After Scenarios

The typical Feature File is made up of one or more Scenarios. When a Feature File is executed, the Scenarios are each run once in sequence from top to bottom. Cycle also supports two special types of Scenarios called Backgrounds and After Scenarios. Backgrounds and After Scenarios consist of a set of Steps exactly like a regular Scenario, however these types of Scenarios get executed differently than regular Scenarios.


Backgrounds are similar to regular Scenarios except the Background is executed before each Scenario is executed in the Feature File. Backgrounds are often suited for data loading and/or cleanup. The Background in the figure below imports the Scenarios from another Feature File to use within this Feature and opens Chrome ahead of time for each Scenario that will follow it.

Example Background

After Scenarios

After Scenarios are similar to Backgrounds, except that they are executed after each Scenario in the Feature. After Scenarios are particularly useful for running cleanup scripts. An After Scenario must come after the Background in a Feature, but before the Scenarios in a Feature.

Example After Scenario

results matching ""

    No results matching ""