当前位置: 首页 > 知识库问答 >
问题:

Cucumber测试没有并行运行(Cucumber jvm并行插件)?

高鸿振
2023-03-14

Cucumber测试没有并行运行(Cucumber jvm并行插件)?

如果我使用runner类执行测试,一次将执行一个功能文件,但是当将以下插件添加到POM文件时,似乎没有功能文件执行?

即使我指向了正确的功能文件文件夹?

我的POM文件:

   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.pim</groupId>
    <artifactId>PimCucumberFramework</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>PimCucumberFramework</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
            <plugin>
  <groupId>com.github.temyers</groupId>
  <artifactId>cucumber-jvm-parallel-plugin</artifactId>
  <version>4.1.0</version>
  <executions>
    <execution>
      <id>generateRunners</id>
      <phase>generate-test-sources</phase>
      <goals>
        <goal>generateRunners</goal>
      </goals>
      <configuration>
        <!-- Mandatory -->
        <!-- List of package names to scan for glue code. -->
        <glue>
          <package>com.example</package>
          <package>com.example.other</package>
        </glue>
        <!-- These are optional, with the default values -->
        <!-- Where to output the generated tests -->
        <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
        <!-- The directory, which must be in the root of the runtime classpath, containing your feature files.  -->
        <featuresDirectory>src/test/java/resources/features</featuresDirectory>
        <!-- Directory where the cucumber report files shall be written  -->
        <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
        <!-- List of cucumber plugins. When none are provided the json formatter is used. For more 
             advanced usage see section about configuring cucumber plugins -->
        <plugins>
          <plugin>
              <name>json</name>
          </plugin>
          <plugin>
              <name>com.example.CustomHtmlFormatter</name>
              <extension>html</extension>
          </plugin>
        </plugins>
        <!-- CucumberOptions.strict property -->
        <strict>true</strict>
        <!-- CucumberOptions.monochrome property -->
        <monochrome>true</monochrome>
        <!-- The tags to run, maps to CucumberOptions.tags property. Default is no tags. -->
        <tags>
          <tag>@important</tag>
        </tags>
        <!-- Generate TestNG runners instead of JUnit ones. --> 
        <useTestNG>false</useTestNG>
        <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' --> 
        <namingScheme>simple</namingScheme>
        <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
        <namingPattern>Parallel{c}IT</namingPattern>
        <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
        <parallelScheme>SCENARIO</parallelScheme>
        <!-- Specify a custom template for the generated sources (this is a path relative to the project base directory) -->
        <customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>
        <!-- Specify a custom package name for generated sources. Default is no package.-->
        <packageName>com.example</packageName>
      </configuration>
    </execution>
  </executions>
</plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.2.5</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
            <scope>test</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all -->
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>1.2.5</version>
        </dependency>

        <!-- Extent Reports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>3.0.5</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.26-incubating</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>3.6.0</version>
        </dependency>
        <dependency>
            <groupId>com.vimalselvam</groupId>
            <artifactId>cucumber-extentsreport</artifactId>
            <version>2.0.4</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps -->
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>

        <!--PROBLEM https://mvnrepository.com/artifact/info.cukes/cucumber-spring 
            <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-spring</artifactId> 
            <version>1.2.5</version> </dependency> <dependency> <groupId>info.cukes</groupId> 
            <artifactId>cucumber-guice</artifactId> <version>1.2.5</version> </dependency> -->
    </dependencies>
</project>

共有1个答案

蒋芷阳
2023-03-14
       <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
        <modelVersion>4.0.0</modelVersion> 
        <groupId>com.pim</groupId> 
        <artifactId>PimCucumberFramework</artifactId> 
        <version>0.0.1-SNAPSHOT</version>    
       <packaging>jar</packaging>   
       <name>PimCucumberFramework</name> 
       <url>http://maven.apache.org</url> 
       <properties>     
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
       <build> 

     <plugins>
      <plugin> <groupId>com.github.temyers</groupId> <artifactId>cucumber-jvm-parallel-plugin</artifactId> <version>4.1.0</version>
         <executions> 
              <execution> 
                 <id>generateRunners</id>           
                 <phase>generate-test-sources</phase> 
                 <goals> 
                      <goal>generateRunners</goal>
                 </goals> 
                 <configuration> 
                 <!-- Mandatory --> 
                 <!-- List of package names to scan for glue code. --> 
                 <glue>
                      <package>stepDefinitions</package> 
                </glue>
                <!-- These are optional, with the default values --> 
                <!-- Where to output the generated tests --> 
                  <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>         
                  <!-- The directory, which must be in the root of the runtime classpath, containing your feature files. -->     
                  <featuresDirectory>src/test/resources/features</featuresDirectory>  
                  <!-- Directory where the cucumber report files shall be written -->    
                 <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                 <!-- List of cucumber plugins. When none are provided the json formatter is used. For more advanced usage see section about configuring cucumber plugins -->
                 <plugins>
                    <plugin> 
                        <name>json</name> 
                    </plugin> 
                </plugins>
                <!-- CucumberOptions.strict property --> <strict>true</strict> 
               <!-- CucumberOptions.monochrome property -->
               <monochrome>true</monochrome> 
              <!-- The tags to run, maps to CucumberOptions.tags property. Default is no tags. -->
             <tags>
                  <tag>~@important</tag> 
            </tags> 
            <!-- Generate TestNG runners instead of JUnit ones. -->
            <useTestNG>false</useTestNG> 
            <!-- The naming scheme to use for the generated test classes. One of 'simple' or 'feature-title' -->    
            <namingScheme>simple</namingScheme> 
            <!-- The class naming pattern to use. Only required/used if naming scheme is 'pattern'.--> 
            <namingPattern>Parallel{c}Test</namingPattern> 
            <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. -->      
           <parallelScheme>FEATURE</parallelScheme> 
          </configuration> 
         </execution> 
        </executions>
        </plugin>
        <plugins>
</build> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.4.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.5</version> <scope>test</scope> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-jvm</artifactId> <version>1.2.5</version> <type>pom</type> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-junit</artifactId> <version>1.2.5</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-core</artifactId> <version>1.2.5</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-html --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-html</artifactId> <version>0.2.3</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-java</artifactId> <version>1.2.5</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-jvm-deps</artifactId> <version>1.0.5</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/gherkin --> <dependency> <groupId>info.cukes</groupId> <artifactId>gherkin</artifactId> <version>2.12.2</version> </dependency> <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all --> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>1.3</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>1.2.5</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-testng --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-testng</artifactId> <version>1.2.5</version> </dependency> <!-- Extent Reports --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>3.0.5</version> </dependency> <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker --> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.26-incubating</version> </dependency> <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting --> <dependency> <groupId>net.masterthought</groupId> <artifactId>cucumber-reporting</artifactId> <version>3.6.0</version> </dependency> <dependency> <groupId>com.vimalselvam</groupId> <artifactId>cucumber-extentsreport</artifactId> <version>2.0.4</version> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-jvm-deps --> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-jvm-deps</artifactId> <version>1.0.5</version> </dependency> <!--PROBLEM https://mvnrepository.com/artifact/info.cukes/cucumber-spring <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-spring</artifactId> <version>1.2.5</version> </dependency> <dependency> <groupId>info.cukes</groupId> <artifactId>cucumber-guice</artifactId> <version>1.2.5</version> </dependency> --> </dependencies> </project>
 类似资料:
  • 我目前正在尝试使用Cucumber实现并行测试运行。我设法使用万无一失的插件同时运行了两个不同的运行程序。现在我想检查是否可以并行运行SingleRunner文件多次。 我有一个签名测试。所以我需要在几个平台上并行运行。有可能吗? 这是我的跑步者档案 无跑道进近 工厂级 `导入org . open QA . selenium . web driver; ` 阶梯班 导入org.openqa.sel

  • Javav8. x-Springv5. xcucumberv4.2.0 我尝试了temyers/cucumber jvm并行插件,效果很好,但当我进入他们的gitihub页面时,他们宣布停止使用该插件b/c cucumber已经开始支持cucumber jvm 4.0的并行测试运行支持。0 我有使用以下maven依赖项的现有测试。 我有两个问题让我困惑。 为了使用cucumber-jvm,我必须更

  • 我是Serenity和BDD的新手。我有一个基于Serenity Cucumber和Page based模型的小型演示项目。项目结构如下: 登录和注销功能大约有8种情况。 我希望能够并行运行功能文件。实现这一点的最简单和最有效的方法是什么? 到目前为止我已经 > 为每个功能创建了单独的 Runner 类,然后使用故障安全或万无一失的插件 - 这是我不想要的,因为我不希望每个功能文件都有新的运行器。

  • 嘿,我在POM中做了这个配置。xml文件并行运行测试。但当我使用cmd进行“mvn验证”时,只有一个浏览器正在运行一个功能,而在完成一个功能文件的执行后,另一个功能正在运行。这是我的代码和pom。xml请建议我怎么做? 我正在使用cucumber 这是我的pom.xml代码: 提前感谢。

  • 我编写了两个功能文件,每个功能文件打开不同的浏览器URL,例如一个是open google。com和secnd一个开放的亚马逊。但事实并非如此。 两个浏览器都打开了谷歌。通用域名格式。此外,它不能与浏览器交互,任何编码到浏览器的操作都不会执行。此外,关闭第一个浏览器会导致第二个浏览器出现空指针异常。 cucumber版本6我从AbstractCucumberTesNG继承开始。然后我创建登录。功能

  • 当我试图在Selenium Grid 2旁边使用TestNG并行运行测试时,我似乎遇到了一个问题。 尽管打开的浏览器数量与我正在运行的测试数量相匹配,但所有测试的所有指令都被发送到同一个浏览器窗口。例如,每个测试都会打开一个页面并尝试登录。四个浏览器窗口将打开,但一个浏览器窗口将导航到登录页面四次,然后键入用户名四次,而其余的浏览器窗口保持不活动。 以下是我如何启动网格: xml套件是这样设置的: