![](/img/trans.png)
[英]How to make a Junit test case fail if there is any exception in the code?
[英]How to explicitly or manually fail a test case in JUnit
在我的 Java / RestAssured / TestNG 框架中,我想写一个具有以下结构的断言
if(responseString.equals("Good Response!")) {
// perform additional assertions here
} else if(responseString.equals("Bad Response!")) {
// just fail the test case right here and now
}
go 关于简单地使测试用例失败而不断言其他任何东西的最佳方法是什么?
不要使用 if,而只是这样做:
assertEquals("Good Response!", responseString);
// perform additional assertions here
如果你只是想失败:
fail("I failed because...");
Assert.assertEquals(true, false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.