为什么我的TestNG xml文件没有针对我的Runner Class?
我的XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Cucumber Framework" verbose="2">
<test name="Cucumber Tests">
<classes>
<class name="runners.MainRunner"></class>
</classes>
</test>
</suite>
跑步者类的位置:
CucumberFramework \ SRC \测试\ java中\ CucumberFramework \跑者 CucumberFramework \ SRC \测试\ java中\ CucumberFramework \参赛者\ MainRunner.java
请注意:如果我直接执行转轮类,一切都运作相应,似乎xml文件无法找到转轮类,任何想法?
亚军类代码:
package CucumberFramework.runners;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@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 {
}
答案 0 :(得分:0)
您可以通过定义属性junit =“true”来执行带有testng xml文件的junit类,如下所示
<suite name="Cucumber Framework" >
<test name="Cucumber Tests" junit="true">
<classes>
<class name="CucumberFramework.runners.MainRunner" />
</classes>
</test>
</suite>