当使用面向以下异常的testng并行运行自动生成的测试运行器时

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当使用面向以下异常的testng并行运行自动生成的测试运行器时相关的知识,希望对你有一定的参考价值。

以下是最新的自动生成的跑步者文件

import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(strict = false,
features = {"C:/Users/mbethu/IdeaProjects/comparalleltestng/src/main/java/java/features/HomePage.feature"},
plugin = {"html:target/cucumber/1.html"},
monochrome = true,
tags = {},
glue = { "java.stepdefinitions" })
public class Parallel01IT extends AbstractTestNGCucumberTests {
}


import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(strict = false,
features = {"C:/Users/mbethu/IdeaProjects/comparalleltestng/src/main/java/java/features/Login.feature"},
plugin = {"html:target/cucumber/2.html"},
monochrome = true,
tags = {},
glue = { "java.stepdefinitions" })
public class Parallel02IT extends AbstractTestNGCucumberTests {
}

下面是最新的testng.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" data-provider-thread-count="3">   <!-- how many scenarios we can execute at a time is mentioned bt data-provider-thread-count-->
    <test  name="ChromeTest" thread-count="5"  >
        <!--  <parameter name="browser" value="chrome"/>-->
        <packages>
            <package name="target.generated-test-sources.cucumber"/>
        </packages>
    </test> <!-- Test -->

</suite> <!-- Suite -->

以下是最新的POM.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<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.parallel</groupId>
    <artifactId>com.parallel.testng</artifactId>
    <version>1.0-SNAPSHOT</version>

    <build>
        <plugins>
        <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>2.1.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <!-- Mandatory -->
                        <!-- comma separated list of package names to scan for glue code -->
                        <glue>java.stepdefinitions</glue>
                        <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>C:UsersmbethuIdeaProjectscomparalleltestngsrcmainjavajavafeatures</featuresDirectory>
                        <!-- Directory where the cucumber report files shall be written  -->
                        <cucumberOutputDir>target/cucumber</cucumberOutputDir>
                        <!-- comma separated list of output formats json,html,rerun.txt -->
                        <format>html</format>
                        <!-- CucumberOptions.strict property -->
                        <strict>false</strict>
                        <!-- CucumberOptions.monochrome property -->
                        <monochrome>true</monochrome>
                        <!-- The tags to run, maps to CucumberOptions.tags property you can pass ANDed tags like "@tag1","@tag2" and ORed tags like "@tag1,@tag2,@tag3" -->
                       <!-- <tags></tags>-->
                        <!-- If set to true, only feature files containing the required tags shall be generated. -->
                        <filterFeaturesByTags>false</filterFeaturesByTags>
                        <!-- Generate TestNG runners instead of default JUnit ones. -->
                        <useTestNG>true</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>FEATURE</parallelScheme>
                        <!-- This is optional, required only if you want to specify a custom template for the generated sources (this is a relative path) -->
                        <!--<customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>-->
                    </configuration>
                </execution>
            </executions>
        </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <fork>true</fork>
                    <executable>C:Program FilesJavajdk1.8.0_201injavac.exe</executable>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.1</version>
            <configuration>
                <!--<forkCount>5</forkCount>
                <reuseForks>true</reuseForks>-->

                <suiteXmlFiles>
                    <suiteXmlFile>src	estjava	estng.xml</suiteXmlFile>
                </suiteXmlFiles>

                <testFailureIgnore>true</testFailureIgnore>
               <parallel>classes</parallel>
                <threadCount>10</threadCount>
               <testErrorIgnore>true</testErrorIgnore>
               <includes>
                   <include>src	estjava	estng.xml</include>
                   <!--<include>**/*IT.class</include>-->
                </includes>
            </configuration>
        </plugin>
        </plugins>

    </build>


    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
       <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
          <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>3.141.59</version>
        </dependency>



        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
           <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>compile</scope>
        </dependency>


        <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-testng -->
        <!--    <dependency>
             <groupId>org.apache.maven.surefire</groupId>
             <artifactId>surefire-testng</artifactId>
             <version>2.22.1</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>-->
      <!-- 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 -->
        <!--      <dependency>
               <groupId>info.cukes</groupId>
               <artifactId>cucumber-jvm</artifactId>
               <version>1.2.5</version>
               <type>pom</type>
           </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>
            <scope>provided</scope>
        </dependency>-->

        <!-- https://mvnrepository.com/artifact/info.cukes/gherkin -->
      <!--  <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
            <scope>provided</scope>
        </dependency>
-->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>2.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable</artifactId>
            <version>1.1.12</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>4.2.3</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
</project>

以下是旧文件

<?xml version="1.0" encoding="UTF-8"?>
<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.parallel</groupId>
<artifactId>com.parallel.testng</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.github.temyers</groupId>
<artifactId>cucumber-jvm-parallel-plugin</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>generateRunners</id>
<phase>generate-test-sources</phase>
 <goals>
 <goal>generateRunners</goal>
 </goals>
 <configuration>
 <!-- Mandatory -->
 <!-- comma separated list of package names to scan for glue code -->
 <glue>java.stepdefinitions</glue>

 <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>C:UsersmbethuIdeaProjectscomparalleltestngsrcmainjavajavafeatures</featuresDirectory>
 <!-- Directory where the cucumber report files shall be written  -->

<cucumberOutputDir>target/cucumber</cucumberOutputDir>
 <!-- comma separated list of output formats json,html,rerun.txt -->
 <format>json,html</format>
 <!-- CucumberOptions.strict property -->
 <strict>false</strict>
 <!-- CucumberOptions.monochrome property -->
 <monochrome>true</monochrome>
 <!-- The tags to run, maps to CucumberOptions.tags property you can 
pass ANDed tags like "@tag1","@tag2" and ORed tags like 
"@tag1,@tag2,@tag3" -->
<tags></tags>
<!-- If set to true, only feature files containing the required tags 
shall be generated. -->
<filterFeaturesByTags>false</filterFeaturesByTags>
<!-- Generate TestNG runners instead of default JUnit ones. -->
<useTestNG>true</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>FEATURE</parallelScheme>
 <!-- This is optional, required only if you want to specify a custom 
 template for the generated sources (this is a relative path) -->
 <!--<customVmTemplate>src/test/resources/cucumber-custom- 
 runner.vm</customVmTemplate>-->
 </configuration>
 </execution>
 </executions>
 </plugin>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-surefire-plugin</artifactId>
 <version>2.19.1</version>
 <configuration>
 <!-- <forkCount>5</forkCount>
 <reuseForks>true</reuseForks>-->

 <suiteXmlFiles>
                <suiteXmlFile>src	estjava	estng.xml</suiteXmlFile>
            </suiteXmlFiles>

            <parallel>classes</parallel>
            <threadCount>10</threadCount>
           <!-- <includes>
                <include>**/*IT.class</include>
            </includes>-->
        </configuration>
    </plugin>
    </plugins>

</build>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>3.141.59</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>compile</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-testng -->
    <dependency>
        <groupId>org.apache.maven.surefire</groupId>
        <artifactId>surefire-testng</artifactId>
        <version>2.22.1</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>

    <!-- 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 -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>1.2.5</version>
        <type>pom</type>
    </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>
        <scope>provided</scope>
    </dependency>

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

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core
  <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-core</artifactId>
      <version>4.2.6</version>
  </dependency>-->

    <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
    </dependency>

</dependencies>

以下是我运行命令时遇到的错误

测试运行:0,失败:0,错误:0,跳过:0

[INFO] ----------------------------------------------- ------------------------- [INFO] BUILD FAILURE [INFO] ----------------- -------------------------------------------------- ----- [INFO]总时间:12.820秒[INFO]完成时间:2019-04-20T16:15:56 + 05:30 [INFO] --------------- -------------------------------------------------- ------- [ERROR]无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test(default-test)项目com.parallel.testng:执行默认测试目标org.apache.maven.plugins:maven-surefire-plugin:2.19.1:测试失败:分叉进程中出错[ERROR] java.lang.NoSuchMethodError:org.apache.maven.surefire.report。 SimpleReportEntry。(Ljava / lang / String; Ljava / lang / String; Ljava / util / Map;)org.apache.maven.surefire.testng.TestSuite.startTestSuite的V [错误](TestSuite.java:46)[错误] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:74)[错误]在org.apache.maven.surefire.testng.TestNGProvider。在Org.apache.maache.surefire.boot.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)[错误] org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess中调用(TestNGProvider.java:120)[ERROR] ForkedBooter.java:242)[错误]在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)[错误] [错误] - > [帮助1] org.apache.maven.lifecycle。 LifecycleExecutionException:无法在项目com.parallel.testng上执行目标org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test(default-test):目标org.apache.maven的执行默认测试。插件:maven-surefire-plugin:2.19.1:测试失败:分叉进程中出现错误java.lang.NoSuchMethodError:org.apache.maven.surefire.report.SimpleReportEntry。(Ljava / lang / String; Ljava / lang / String; Ljava / util / Map;)V org.apache.maven.surefire.testng.TestSuite.startTestSuite(TestSuite.java:46)at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite。 java:74)在org.apache。 maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)位于org.apache.maven.surefire.booter.ForkedBooter的org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)。 runSuitesInProcess(ForkedBooter.java:242)at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject

(LifecycleModuleBuilder.java:117)在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java :56)在org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)在org.apache.maven.DefaultMaven。 doOecute(DefaultMaven.java:192)org.apache.maven.maven.DefaultMaven.execute(DefaultMaven.java:105)org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)atg.apache.maven .cli.MavenCli.doMain(MavenCli.java:288)在org.apache.maven.cli.MavenCli.main(MavenCli.java:192)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl .invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.in vo(Method.java:498)org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225) org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)引起:org.apache.maven .plugin.PluginExecutionException:目标的执行默认测试org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed:分叉进程java.lang.NoSuchMethodError:org.apache中出错。 maven.surefire.report.SimpleReportEntry(Ljava /郎/字符串; Ljava /郎/字符串; Ljava / util的/地图;):V在org.apache.maven.surefire.testng.TestSuite.startTestSuite(TestSuite.java:46)在org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:74)在org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)在org.apache.maven.surefire .booter.ForkedBooter.inv okeProviderInSameClassLoader(ForkedBooter.java:290)在org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)在org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject

(LifecycleModuleBuilder.java:117)org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)at

 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build

(SingleThreadedBuilder.java:56)org.apache.maven.macycle.life.internal.LifecycleStarter.execute(LifecycleStarter.java:128)org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)atg.apache。 maven.DefaultMaven.doExecute(DefaultMaven.java:192)org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)atg.apache.maven.cli.MavenCli.execute(MavenCli.java:956)org .apache.maven.cli.MavenCli.doMain(MavenCli.java:288)org.apache.maven.cli.MavenCli.main(MavenCli.java:192)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)位于org.codehaus的java.lang.reflect.Method.invoke(Method.java:498)的sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)。在org.codehaus.plexus.classworlds.launch的org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)上的plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282) er.Launcher.mainWithExitCode(Launcher.java:406)at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)引起:java.lang.RuntimeException:分叉进程出错java.lang.NoSuchMethodError:org.apache.maven.surefire.report.SimpleReportEntry。(Ljava / lang / String; Ljava / lang / String; Ljava / util / Map;)V org.apache.maven.surefire.testng。位于org.apache.maven.surefire.Tern.TestN.Ravrovider.j上的org.apache.maven.surefire.testng.TestNGXmlTestSuite.exe(TestNGXmlTestSuite.java:74)中的TestSuite.startTestSuite(TestSuite.java:46)(TestNGProvider.java: 120)org.apache.maven中的org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242) .surefire.booter.ForkedBooter.main(ForkedBooter.java:121)

at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork (ForkStarter.java:584)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork (ForkStarter.java:460)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run (ForkStarter.java:229)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run (ForkStarter.java:201)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider

(AbstractSurefireMojo.java:1026)在org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:862)在org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:755)在org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)在org.apache.maven.lifecycle.internal。 MojoExecutor.execute(MojoExecutor.java:156)在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java: 117)在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)在有机.apache.maven.lifecycle.internal.LifecycleStarter .execute(LifecycleStarter.java:128)org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)atg.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)org.apache.maven。 org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)上的org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)中的DefaultMaven.execute(DefaultMaven.java:105) .apache.maven.cli.MavenCli.main(MavenCli.java:192)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect.DelegatingMethodAccessorImpl .invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.invoke(Method.java:498)在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)在有机codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)at org.codehaus.plexus.classworlds.lau ncher.Launcher.main(Launcher.java:347)[ERROR] [ERROR] [ERROR]有关错误和可能的解决方案的更多信息,请阅读以下文章:[错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

答案

你正在使用info.cukes依赖,这是非常古老的支持黄瓜直到v 1.2.5并且在2016年9月12日之后没有更多的支持,这就是你必须仍然使用cucumber-jvm-parallel-plugin并做很多的原因动态生成每个特征文件的单个转轮所需的配置。

请尝试遵循并实施Cucumber V 4.0.X,不仅要实现并行执行,而且要保持更新,以下是实现此目的的步骤。

1.添加正确的依赖集。我在实现过程中遵循了JUnit。

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>4.2.3</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.3</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>datatable</artifactId>
    <version>1.1.12</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.3</version>
    <scope>test</scope>
</dependency>

2.在POM.XML下添加Maven-Surefire-Plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0-M3</version>
    <configuration>
        <parallel>methods</parallel>
        <threadCount>1</threadCount>
        <reuserForks>false</reuserForks>
        <testErrorIgnore>true</testErrorIgnore>   
        <testFailureIgnore>true</testFailureIgnore>
        <includes>
            <include>**/*RunCukeTest.java</include>
        </includes>
    </configuration>
</plugin>

注 - TestNG依赖性导致Surefire忽略JUnit包装类。如果不需要,则删除所有TestNG依赖项,或者您可以调用2定义2执行一个用于TestNG和其他用于JUnit并根据需要禁用一个。使用JUnit的人面临的问题是一切正常,但仍然是单次测试运行。所以我们也必须保持这一点。

以上是关于当使用面向以下异常的testng并行运行自动生成的测试运行器时的主要内容,如果未能解决你的问题,请参考以下文章

如何使用带有geb的testng并行运行执行测试类

并行运行 TestNG QAF BDD 测试

如何在 TestNG 中并行运行测试用例?

并行运行测试时,testng-results.xml 文件被覆盖

如何在并行 JVM 进程(不是线程)中运行 TestNG 测试

使用TestNG运行代码时出现空指针异常