没有为 TestNG 执行测试

Tests are not being executed for TestNG

尝试 运行 我所有的 Cucumber 测试都使用 TestNG。但是找不到我的套件。

我看到了一些关于它的 Whosebug 问题,但是 none 解决了我的问题。

亚军 - junitRunner.java

package testRunner;

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;

//@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/test/resources/features/",
glue = "br.mysteps.steps"
)

public class junitRunner {

}

testng.xml

<suite name="SeleniumSuite">
<test name="testAll">
       <classes>
          <class name="testRunner.junitRunner"/>
       </classes>
</test>
</suite>

pom.xml

<dependencies>
    <dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>1.2.5</version>
</dependency>

    <dependency>
        <groupId>org.testng</groupId>       
        <artifactId>testng</artifactId>
        <version>6.11</version>
    </dependency>
</dependencies>

当我运行将testng.xml文件作为TestNG时,找不到如下测试

[RemoteTestNG] detected TestNG version 6.11.0
[TestNGContentHandler] [WARN] It is strongly recommended to add "<!DOCTYPE 
suite SYSTEM "http://testng.org/testng-1.0.dtd" >" at the top of your 
file, otherwise TestNG may fail or not work as expected.

===============================================
SeleniumSuite
Total tests run: 0, Failures: 0, Skips: 0
===============================================

如果您想基本上使用 TestNG 来 运行 您的黄瓜测试,那么您需要扩展 cucumber.api.testng.AbstractTestNGCucumberTests.

有关如何使用 TestNG 运行 黄瓜测试的更多详细示例,请参阅示例 here