如何在 JUnit 中显式或手动使测试用例失败
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
}
在不声明任何其他内容的情况下简单地使测试用例失败的最佳方法是什么?
不要使用 if,而只是:
assertEquals("Good Response!", responseString);
// perform additional assertions here
如果你只是想失败:
fail("I failed because...");
Assert.assertEquals(true, false);
在我的 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
}
在不声明任何其他内容的情况下简单地使测试用例失败的最佳方法是什么?
不要使用 if,而只是:
assertEquals("Good Response!", responseString);
// perform additional assertions here
如果你只是想失败:
fail("I failed because...");
Assert.assertEquals(true, false);