黄瓜4.2:每个浏览器都有独立的运行器

时间:2018-11-17 02:54:09

标签: java automated-tests cucumber cucumber-jvm

我只为chrome浏览器实现了Cucumber 4.2并行执行。现在,我想为两个浏览器(Firefox / Chrome)实现并行执行。请提供示例或框架,以便我可以从中进行改进。此外,在哪里可以找到Cucumber API Javadoc?

Chrome Runner:

public class ChromeTestNGParallel {

    @Test
    public void execute() {
        //Main.main(new String[]{"--threads", "4", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"});
        String [] argv = new String[]{"--threads", "8", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"};
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        byte exitstatus = Main.run(argv, contextClassLoader);
    }

}

Firefox Runner:

public class FirefoxTestNGParallel {

    @Test
    public void execute() {
        //Main.main(new String[]{"--threads", "4", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"});
        String [] argv = new String[]{"--threads", "8", "-p", "timeline:target/cucumber-parallel-report", "-g", "com.peterwkc.step_definitions", "src/main/features"};
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
        byte exitstatus = Main.run(argv, contextClassLoader);
    }

}

这就是我想要的。 Cucumber_Design

1 个答案:

答案 0 :(得分:0)

我认为您可以在Cucumber之外进行此操作。

第一部分是使用命令行参数或环境将Cucumber配置为与特定的浏览器一起运行。

第二部分是运行两个(或同时运行多个黄瓜实例)。基本上使用虚拟机来执行此操作,只需运行带有不同命令行参数的Cucumber即可配置浏览器。

您甚至可以使用Circle CI之类的付费服务为您完成这项工作。