java - 在测试标签级别使用允许返回值
问题描述
我正在尝试allow-return-value = "true"
在测试级别使用。当我运行代码时,返回类型为 non-void 的方法仍然被忽略,因为我希望调用它,因为 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
解决方案
推荐阅读
- matlab - Matlab polyfit 的根,带有 mu 用于居中和缩放
- mysql - 将phpmyadmin上的数据导入多个表
- rust - 从函数返回未来值
- javascript - JS - 带图像的单选按钮
- java - Spring Boot 应用无法使用 SSH 启动
- android - 在 AMD 处理器上运行 android 模拟器
- veins - 802.11p 中是否有最大单播消息数?
- angular - Angular 9:为什么我的自定义 EventEmitter 不起作用?
- reactjs - 单击 /profile 后,我登陆路径 /login。在 /profile 上再次完成登录后如何自动登陆?
- java - 将文件发送到 PHP