Geek
Geek

Reputation: 99

How to validate using conditional statement

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

Upvotes: 1

Views: 237

Answers (1)

Christoph Deppisch
Christoph Deppisch

Reputation: 2216

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.

Upvotes: 1

Related Questions