Skip to main content

REST Assured: Log if Error or if the status code matches some value

If you're only interested in printing the response body if an error occur then you can use:

.log().ifError()

make sure you are using .log().ifError() just after than otherwise logs will not show. It logs everything only if an error occurs (status code >= 400).

Log only the status

.log().status();		

Log is status code is equal to

.log().ifStatusCodeIsEqualTo(202)

log if the status code matches the supplied Hamcrest matcher

.log().ifStatusCodeMatches(equalTo(200));	
Video Tutorial

About

Elix is a premium wordpress theme for portfolio, freelancer, design agencies and a wide range of other design institutions.