I’m facing one issue (maybe the solution is simple, but I don’t know it ).
I have an “IF” statement to compare two integers, and want to fail the test if the condition is false. My code is as follow:
if ( integer x < integer y) {
do some actions (verify, click …)
} else { I want the test to fail here … but how?
}
the benefit of keyword is that you can pass also a message with failure reason to the test report.
the assert one is just a quick universal workaround, not dependant on the framework
(but you can do also a print/log before the assert)
If an assert fails, it shows the TC run status with ‘ERROR’. How to fail a test case if an assert fails ?
Caused by: java.lang.AssertionError: The expected value for orderStatus was not found in the response… Expression: (value.toString().equalsIgnoreCase(text) == true)
at com.ge.automation.api.utils.Utils.verifyValueInResponse(Utils.groovy:74)
… 14 more
Test Cases/API-Tests/InvestigationFollowUpOrderTest
ERRORPreformatted text
@harshita.singh If I understand correctly, the concern you have is that “value” is null, so you can test if value is null (or not null) and do some other statement that will fail. As an example ( as a note you do not need to test if the value.toString() is true as the value.toString() statement is a boolean condition in itself):