How to validate using conditional statement

228 views Asked by At

I designed a customized reporting template, I am wondering how to put the report block inside a conditional statement.

For Example:

If the Below code execute succesfullt and status is Failed, Then how to capture it inside my report.

    http()
        .client(todoClient1)
        .receive()
        .response(HttpStatus.OK)
        .validate("$.statusCode", "202");

Thanks In Advance BJ

1

There are 1 answers

3
Christoph Deppisch On BEST ANSWER

Your custom reporter should implement TestListener interface that is called with failed test state when something went wrong during the test. The failed state includes the failure stack trace as well as the exception cause. Also the listener is provided with test case object that provides the method getLastExecutedAction(). This is the last executed action that caused the failure.

Also the conditional block action provides direct access to the nested actions in the conditional container for detailed customized reporting then.