问题:TestNG:通过 testng 运行测试时“未找到测试”

我正在尝试通过 testng.xml 运行简单的 Cucumber/Java 测试。

所以,我有 testng.xml:

<?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Cucumber Framework">
<test name="Cucumber Tests" junit="true">
    <classes>
        <class name="CucumberFramework.runner.MainRunner"></class>
    </classes>
</test>
</suite>

我正在使用 runner.class,在其中我将路径/选项/等设置为功能文件、步骤和报告:

package CucumberFramework.runner;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)

@CucumberOptions (
        features = {"src/test/java/CucumberFramework/featureFiles"},
        glue = {"CucumberFramework.steps"},
        monochrome = true,
        tags = {},
        plugin = {"pretty",
                "html:target/cucumber",
                "json:target/cucumber.json",
                "com.cucumber.listener.ExtentCucumberFormatter:target/report.html"}
)

public class MainRunner extends AbstractTestNGCucumberTests {
}

但是当我将我的 testng.xml 作为 TestNG 套件运行时,它:

1)自己传递我的场景,

2)抛出“未找到测试”。 在此处输入图像描述

我究竟做错了什么?

解答

@SubOptimal - 谢谢伙计,解释得这么清楚,现在我知道更多了。

关于麻烦本身 - 最后我只是通过删除 testng.xml 中提到的 junit 来解决它。正如我在描述中提到的“作为 testng 套件运行”,我应该将此答案标记为正确,没有冒犯。

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐