我正在尝试在测试级别使用allow-return-value = "true"
。当我运行代码时,返回类型为非无效的方法仍会被忽略,因为allow-return-value显式设置为true。当我在套件级别执行此操作时,它完全可以正常工作:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Retrun value True" >
<test verbose="2" preserve-order="true" allow-return-values="true" name="TestNGExperiment">
<classes>
<class name="TestNGExperiment"/>
</classes>
</test>
</suite>
public class TestNGExperiment {
@Test(testName = "divide4by2")// the method with a return type
public int divide4by2() {
System.out.println("divide4by2 called");
return 4/2;
}
@Test(testName = "printHello")
public void printHello() {
System.out.println("Hello");
}
}
实际结果:
运行的总测试次数:1,通过:1,失败:0,跳过:0
根据我的预期结果:
运行的总测试次数:2,通过:2,失败:0,跳过:0