In my Java / RestAssured / TestNG framework, I want to write an assertion with the following structure
if(responseString.equals("Good Response!")) { // perform additional assertions here } else if(responseString.equals("Bad Response!")) { // just fail the test case right here and now }
What is the best way to go about simply failing the test case without asserting anything else?
Advertisement
Answer
Don’t use the if, instead just do:
assertEquals("Good Response!", responseString); // perform additional assertions here
If you simply want to fail:
fail("I failed because...");