简体   繁体   中英

Any other way to run cucumber scenario multiple times other than from scenario outline?

Scenario outline :

  • Given I have a stream from system-env
  • When I request the streaming url
  • Then A http response 200 received
  • And I verify "data1" is accurate
  • And I verify "data2" is accurate

Examples:

  |data1|data2|

  |abc|def|

  |test1|test2 |

What is the best way to make sure the above scenario is run for different input "stream" (currently received from system property to gradle task for a single stream as a tag and scenario is tagged with the same)?

I want to scale it to 50 streams or 100 streams later, I don't want to add all of those examples in examples as its too tedious.

I am thinking to collect all streams from an yaml file (suppose 50) and run the above scenario for each stream.

Here is the high level approach that you can follow using the Jackon library to read the data from yaml and use it in the script. You can get the stream url based on the system variable stream which holds the index of the streams.

Given("^I have the stream from system-env$", () ->
{
    String myTargetStream ="";
    String[] streams = get_text_from_yaml_using_jackon_library_here;//you have to implement this
    int stream = System.getProperty("stream");
    if (stream+1>streams.length){
        myTargetStream = streams[0];
        System.setProperty("stream", "0");
    }else{
        myTargetStream = streams[stream+1];
        System.setProperty("stream", Integer.toString(stream+1));
    }
    // now use the myTargetStream in your test or generate the feature file here
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM