首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >黄瓜6+ JUnit 5+ Spring并行场景执行

黄瓜6+ JUnit 5+ Spring并行场景执行
EN

Stack Overflow用户
提问于 2022-02-07 14:15:19
回答 2查看 530关注 0票数 1

我已经阅读了很多文档、文章和文章,据说在一个功能文件中并行运行场景的开箱即用的解决方案是不可能的。我们可以使用maven-surefire-plugin在并行不同的特性文件中运行,但不能使用场景。

例如,有一个带有场景的特性文件:

代码语言:javascript
复制
Feature: Parallel Scenarios

    Scenario: First
        ...

    Scenario: Second
        ...

    Scenario: Third
        ...

我想在分离的线程中同时运行所有这些场景。

我怎样才能做到这一点?

EN

回答 2

Stack Overflow用户

发布于 2022-02-15 20:50:29

我使用testNGcourgette-jvm在场景级运行并行测试。这是runner文件

代码语言:javascript
复制
import courgette.api.CourgetteOptions;
import courgette.api.CourgetteRunLevel;
import courgette.api.CucumberOptions;
import courgette.api.testng.TestNGCourgette;
import org.testng.annotations.Test;

@Test
@CourgetteOptions(
        threads = 10,
        runLevel = CourgetteRunLevel.SCENARIO,
        rerunFailedScenarios = true,
        rerunAttempts = 1,
        showTestOutput = true,
        reportTitle = "Courgette-JVM Example",
        reportTargetDir = "build",
        environmentInfo = "browser=chrome; git_branch=master",
        cucumberOptions = @CucumberOptions(
                features = "src/test/resources/com/test/",
                glue = "com.test.stepdefs",
                publish = true,
                plugin = {
                        "pretty",
                        "json:target/cucumber-report/cucumber.json",
                        "html:target/cucumber-report/cucumber.html"}
        ))
class AcceptanceIT extends TestNGCourgette {
}

然后使用常规webdriver,我使用RemoteWebDriver

代码语言:javascript
复制
  protected RemoteWebDriver createDriver() throws MalformedURLException {
     //wherever grid hub is pointing. it should work without grid too
    String hubURL = "http://localhost:xxxx/wd/hub";

         ChromeOptions options = new ChromeOptions();
         DesiredCapabilities capabilities = DesiredCapabilities.chrome();
         capabilities.setCapability(ChromeOptions.CAPABILITY, options);
         return (RemoteWebDriver) (driver = new RemoteWebDriver(new URL(hubURL), capabilities));
        
    }

     public RemoteWebDriver getDriver() throws MalformedURLException {
           if (driver == null) {
                         this.createDriver();
           }
            return (RemoteWebDriver) driver;
    }

您可能必须利用这些依赖关系。

代码语言:javascript
复制
      <dependency>
        <groupId>io.github.prashant-ramcharan</groupId>
        <artifactId>courgette-jvm</artifactId>
        <version>5.11.0</version>
    </dependency>
          <dependency>
      <!-- httpclient dpendendecy is to resolve courgette-jvm error -  NoClassDefFoundError: org/apache/http/conn/ssl/TrustAllStrategy -->        
     <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.10</version>
    </dependency>
      <dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
</dependency>
      <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>6.9.1</version>
</dependency>
票数 1
EN

Stack Overflow用户

发布于 2022-12-04 21:46:30

例如,两个测试框架具有并行执行和“Allure”屏幕截图(当步骤失败时)。自述中关于github的所有详细资料:

https://github.com/simileyskiy/cucumber7-selenium3.selenide5-junit5-Allure-parallelExecution

https://github.com/simileyskiy/cucumber7-selenium4.selenide6-junit5-Allure-parallelExecution

票数 -7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71020032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档