Tag logic for Parallel Run

2019-07-23 16:44发布

问题:

The logic for tags via Parallel method is not the same as cucumber options. Would be great if there can be some documentation.

mvn -Doptions="--tags @integration --tags @x --tags ~@wip" doesn't work for scenario with tags as integration Or x

Based on my understanding the above represent @CucumberOptions(tags = {"@integration","@x","~@wip"}

if I give mvn -Doptions="--tags @integration,@x" then it will execute scenario's with tag integration or x.

public static List<String> setTags(String options){
    logger.info("Tag input from  maven command:"+options);
        logger.info("Parsing all the tags");
        List<String> allTags = new ArrayList<>();
        List<String> tags = Arrays.asList(options.split("--tags"));
        for (String tag : tags) {
            if (StringUtils.isNotEmpty(tag)) {
                logger.info("Tags selected are:" + tag.trim());
                allTags.add(tag);
            }
        }
        return allTags;

}

public static List<String> getTags(){
    if(StringUtils.isNotEmpty(System.getProperty("options"))) {
        return setTags(System.getProperty("options"));
    }else throw new RuntimeException("Please select a tag for execution");
}

Parallel Method where I am getting all the feature files in a director and passing the tags as List.

    KarateStats stats = CucumberRunner.parallel(PipelineRunner.getTags(), PipelineRunner.getAllFeatureFiles(featureDir), 1, karateOutputPath);

File 1 @integration

Scenario:blah blah

File 2 @x

Scenario:blalh blah

回答1:

Based on my understanding the above represent @CucumberOptions(tags = {"@integration","@x","~@wip"}

No, that's wrong. Refer to this blog post and it is even linked to from the Karate documentation: https://testingneeds.wordpress.com/2015/09/15/junit-runner-with-cucumberoptions/

This should be what you are looking for.

@CucumberOptions(tags = {"@integration,@x", "~@wip"})

If you still see issues, we can fix it - but kindly follow the process here: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue



标签: karate