未为TestNG执行测试

时间:2019-10-02 08:38:41

标签: java automated-tests cucumber testng

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

我看到了一些关于stackoverflow的问题,但都没有解决我的问题。

Runner-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运行testng.xml文件时,找不到以下测试

[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
===============================================

1 个答案:

答案 0 :(得分:1)

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

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