question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

log().ifError() is not printing the response body in case of failure

See original GitHub issue

I’ve below code

	@Test(timeout=10000)
	public void test_xxxx_endpoint(){
                                             given().
                                	       		   log().all().
                                                           header("Accept", "application/json; version=1.0").
                                                           header("Authorization", "JWT "+ token ).
                                               when().
                                            	           get(urlValue +"/transitions/").
                                               then().
                                            	          statusCode(200).
                                            	          //log().all().  this also has same issue
                                            	          log().ifError().
                                            	          time(lessThan(maxResponseTime), TimeUnit.MILLISECONDS);	
}

When the response is not 200, it doesn’t print the response body instead I get exception throw.

Please review

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
johanhalebycommented, Mar 3, 2017

You need to place logging before you start your assertions, i.e. before statusCode(..)

0reactions
pratapan9commented, Mar 4, 2020

Dont find log().ifFailure() at all… Is it log().ifValidationFails()

Read more comments on GitHub >

github_iconTop Results From Across the Web

REST Assured Log Response if Error or Status Code Matches ...
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...
Read more >
How to log Request only if response contains an HTTP error ...
I've tried these snippets but end up with ALL requests logged and only the error responses logged. The problem is that my log...
Read more >
Logging in Rest Assured ( Response Logging ) - Part 2
body() to the response you'll receive information about what the server sends in the response body. It will log the response even if...
Read more >
Log if Error or if the status code matches some value - YouTube
If you're only interested in printing the response body if an error occur then you can use:
Read more >
Error, IfError, IsError, and IsBlankOrError functions in Power ...
Error, IfError, IsError, IsBlankOrError functions in Power Apps ... IsError( Blank() ), The argument is a blank, but not an error. false.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found