0

我有一个内部使用 Cucumber-jvm 的 maven 测试项目。我想使用 Selenium-Grid 2.0 并行运行我的功能文件。

我已经启动了集线器和节点,但是当我运行测试时。它仅在一个 chrome 实例中按顺序运行测试。虽然我可以在集线器上看到 4 个 chrome 实例。

下面是我的@Before 钩子。

@Before
    public void beforeScenario() throws Exception{
        //grid code
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setBrowserName("chrome");
        cap.setPlatform(Platform.MAC);
        cap.setCapability("version", "41");
        driver = new RemoteWebDriver(
                new URL("http://localhost:4444/wd/hub"),
                cap);

        endUser.is_the_login_page();

    }

一些帮助会很有用。谢谢

4

2 回答 2

0

使用surefire插件应该可以做到这一点:http ://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

于 2015-04-07T09:33:18.817 回答
0

您是使用一个测试类还是多个?单个测试类将单线程运行。这样就可以重用了。如果你:

  • 标记功能文件和场景 @firefox 和 @chrome
  • 基于@chrome 和@firefox 标签创建钩子来配置chrome vs firefox
  • 然后使用过滤到@firefox和@chrome的单独测试类
  • 确保您的 junit runner 将允许分叉同时运行多个测试

然后你应该看到你的测试同时在两个容器中运行。

于 2015-03-31T20:27:31.583 回答