What happens when I import Feature Files that have Scenarios with the same name?

What happens when I import Feature Files that have Scenarios with the same name?

Problem

If multiple Feature Files that contain Scenarios with the same name are imported and then a Scenario with a name that exists in multiple files is executed, what will Cycle do? 

Solution

When multiple Feature Files are imported that have Scenarios with the same names, the Scenario within the Feature File last imported will be executed.

 Unique Scenario naming is encouraged when possible. Having Scenarios with the same name will not prevent Cycle from functioning, but repeating Scenario names will make reusing Scenarios and troubleshooting errors more complicated.

Example

mceclip0.pngmceclip3.png

mceclip4.png

In this example FeatureB is the last Feature File to be imported. The Hello World Scenario within FeatureB will be executed, and the output with be “FeatureB”.

Tip

It is best not to have Scenarios in different files with the same name. If they contain the same functionality then place them in a Utility or shared file for reuse by any Feature that requires that specific Scenario execution. If the Scenarios do not contain the same functionality then it is advised to use distinct names.

    • Related Articles

    • Structuring Feature files.

      Problem With multiple developers writing tests on the same project, inconsistent Feature File structure can lead to overlaps in test coverage and reduce test readability. Solution Adopting a modular approach Many common computer interactions are ...
    • How to use Scenario tag filters

      Cycle 2.5 introduces the ability to filter tags during Feature and Playlist execution. This allows the Cycle user more control over which Scenarios within a Feature or Playlist are executed while also allowing more flexibility when assigning tags to ...
    • How to use a CSV file as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • How to use MOCA Examples as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • How to make better Cycle tests with Backgrounds and After Scenarios.

      Problem Cycle Features can often require set-ups before a system is in the correct state to begin the test or cleanup after having run to return everything to a clean state. Solution Cycle includes the ability to use two special types of Scenarios ...