在 Cucumber-JVM Parallel Plugin 成功创建 Runner 之后,似乎 Maven Surefire 正在尝试连接到 TestNG 以获得 运行 个测试用例

Seems Maven Surefire is trying to connect to TestNG for running test cases after Cucumber-JVM Parallel Plugin creates Runner successfully

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

似乎 Maven Surefire 正在尝试使用 Cucumber-JVM 并行插件创建的 运行ners 配置 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] ------------------------------------------------------------------------

我在 cucumber 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>

Cucumber 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,最后它说构建成功并且没有执行测试用例。请指导。

问题是因为对 testNG 的依赖导致 Surefire 忽略 JUnit 包装器 class。我删除了所有 TestNG 依赖项,或者您可以调用 2 define 2 execution - For TestNG & JUnit 并根据需要禁用一个。

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