在Cucumber-JVM并行插件成功创建Runner之后,似乎Maven Surefire尝试连接到TestNG以运行测试用例

时间:2019-02-17 19:11:19

标签: cucumber-jvm

环境-黄瓜V.4.2.3 |硒V.3.8.1 | JUnit V.4.12 | cumming-jvm-并行插件V.5.0.0 | maven-surefire-plugin V.2.22.1 | maven-compiler-插件v.3.3

似乎Maven Surefire尝试使用Cucumber-JVM Parallel Plugin创建的运行程序来配置TestNG。我想通过Junit而不是TestNG运行。不确定为什么要连接到TestNG。

[INFO] Running TestSuite
Configuring TestNG with: TestNG60Configurator
[TestNG] [ERROR] No test suite found. Nothing to run
Usage: <main class> [options] The XML suite files to run

Configuring TestNG with: TestNG60Configurator
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.573 s - in TestSuite
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.108 s
[INFO] Finished at: 2019-02-18T00:28:10+05:30
[INFO] ------------------------------------------------------------------------

在黄瓜jvm并行插件中,我已经提到useTestNg为false。

Maven Surefire插件配置

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
            <forkCount>2</forkCount>
            <reuserForks>true</reuserForks>
            <includes>
                <include>**/Parallel*IT.class</include>
            </includes>
        </configuration>
    </plugin>

黄瓜JVM并行插件-

<plugin>
        <groupId>com.github.temyers</groupId>
        <artifactId>cucumber-jvm-parallel-plugin</artifactId>
        <version>5.0.0</version>
        <executions>
            <execution>
                <id>generateRunners</id>
                <phase>generate-test-sources</phase>
                <goals>
                    <goal>generateRunners</goal>
                </goals>
                <configuration>
                    <glue>
                        <package>com.jacksparrow.automation.steps_definitions.functional</package>
                    </glue>
                    <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                    <featuresDirectory>src/test/resources/features/functional/</featuresDirectory>
                    <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>

                    <plugins>
                        <plugin>
                            <name>json</name>
                        </plugin>
                    </plugins>

                    <useTestNG>false</useTestNG>

                    <namingScheme>simple</namingScheme>
                    <!-- The class naming pattern to use. Only required/used if naming scheme 
                        is 'pattern'. -->
                    <namingPattern>Parallel{c}IT</namingPattern>

                    <!-- CucumberOptions.strict property -->
                    <strict>true</strict>
                    <!-- CucumberOptions.monochrome property -->
                    <monochrome>true</monochrome>
                </configuration>
            </execution>
        </executions>
    </plugin>

有人可以指导我为什么Surefire尝试配置TestNG来运行生成的运行程序,最后说生成成功并且没有执行测试用例。请指导。

2 个答案:

答案 0 :(得分:0)

问题是由于对testNG的依赖导致Surefire忽略JUnit包装器类。我删除了所有TestNG依赖项,或者可以调用2定义2执行-对于TestNG和JUnit并根据需要禁用一个。

答案 1 :(得分:0)

只想把我的2美分放在这里,因为这个答案使我朝着正确的方向前进。我对TestNG有0个依赖项(即使有效的POM也没有),并且我的POM中没有surefire配置。我在配置surefire的POM中添加了一个插件(我在maven surefire junit中进行了搜索),现在“测试”步骤不再引用TestNG。