Automaticaly print service details when validation fails

When validation of a web service call is performed within a test object and the validation fails, it will be great if, instead of printing out the application stacktrace, the service details (URL, Body if exists, and response) will be printed to the console to help anlize what went wrong.

Whenever a tests fails, if the validation is performed in the test object, or I don’t already print the request and the response (and you can’t even print the body, or at least I didn’t find how to do so), I need to remove the validations and include a printout of the request and the response in the test body or get the necessary values in order to run the test object by itself, taking me a lot of time to debug the problem.

  1. I can continue my job, but my performance is lower than expected

Failed validations raises exceptions.
So you can use a try/catch to log additional info’s in case of failure

Thanks Bionel for the info, but doing it that way will force me to add try-catch blocks and related sentences to each of my 500 plus test objects individually, if the program can do it automatically for me it will be a great solution, the idea of using a UI approach to testing services is to have testers with less programming skills to be able to create new tests not depending on them knowing how to code a test.

unfortunately yes … you have to update all testcases.

a possible solution is to write a custom keyword … i will try to make a sample code when the time afford it.

you still have to update all testcases, replacing the built in send request with the custom one, so for the existing cases it is still a pain but it may help you for further projects

personally i don’t use test objects for each and every request, bust only few (let’s say one GET, one POST, one PUT and one DELETE), fully parametrized (baseURL, endpoint, parameters) and i use them by passing variables accordingly … exactly for this purpose, in case of changes needed i don’t have to update thousand objects

otherwise you can simply add into your testcases a ‘comment’ line to print the request/response data no matter if the test passes or fail … but that will make your logs a bit noisy.

however, note that, for each request sent, there is a .har file generated which contains all the data about the request and the response received (check the console output), so if you need this just for debugging … simply use that information :slight_smile: you have everything in that file

see pic for testcase console:

and same when using the request objects repository:

1 Like