With multiple developers writing tests on the same project, inconsistent Feature File structure can lead to overlaps in test coverage and reduce test readability.
Many common computer interactions are reused when performing tasks even across functional areas. If an interaction is reused more than once, it should be modularized. This modularization relies on importing Feature Files and reusing Scenarios. There are a number of reasons to implement a modular approach to Feature development with Cycle:
It is therefore recommended that different functions be written into discrete Scenarios. Like Scenarios can then be grouped into the same Feature, for efficient importing and reuse by other functional Features.
One example of a useful way to implement modularization is to create a Feature File, named “Environment.feature”, containing Scenarios to configure the environment(s) for a given set of tests. This Feature can then imported into main Feature Files via the Background of Feature Files, or directly into functional Scenarios when it makes sense. Environment.feature could contain Scenarios that configure setup data like connection Information (connection strings, user, password), device codes, or any other data that might be specific to a PC or user.
A Feature File is made up of the following sections, in the following order:
1. Feature Header (optional, but recommended) - Using comments, a Feature Header section should be added to the beginning of all Feature Files to specify the Cycle version and the application version being tested, assumptions, and usage instructions.
2. Background (optional, one per Feature) - The Background (one per Feature) is a specific type of Scenario that runs prior to every non-@wip Scenario in a Feature File. In many cases, it is useful to import Environment.feature via the Background. As described above, Environment.feature would contain Scenarios to set up the test environment for the Scenarios.
3. After Scenario (optional, one per Feature) - The After Scenario, which runs after each non-@wip Scenario in a Feature, can be used for cleaning and purging data used in Scenarios.
4. Functional Scenarios - Functional Scenarios are the main, function-specific execution Scenarios and @wip Scenarios included in the Feature File.