This is a migrated thread and some comments may be shown as answers.

Full Body Verification

3 Answers 269 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marco
Top achievements
Rank 1
Marco asked on 30 Mar 2017, 02:06 PM

There is any way that, in the verification, has a body as expected?

I want to validate that the same get will always have the same response and for that, I need to have the body  as expected

 

Ideally, would be nice to have the expected a file path to the json

How to handle with this ? 

3 Answers, 1 is accepted

Sort by
0
Oleg
Telerik team
answered on 31 Mar 2017, 03:39 PM
Hello,

The short answer to that question is: yes, that is possible, but with some caveats (please see the screenshots and the sample project attached).

In order to verify the full value of a response body, you can just create a verification, set the Source field to "Body" and leave the "Value Path" empty, which will get the full body content. You will need to either paste the expected value of the body in the "Expected" field of the verification or create a variable with that value and refer to that variable from the "Expected" field.

Please see the attached screenshots - I have provided some instructions and also comments on the existing limitations of the current versions (and the workarounds available).

As for comparing the response body against an external json file - that is not available, but we will consider the options and other business applications of comparison operations against files. Please feel free to submit a feature request for that on our feedback portal.

Please let me know if I can be of further assistance.
 
Regards,
Oleg
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Kai
Top achievements
Rank 1
answered on 15 Aug 2018, 08:38 AM
Hey Oleg,

after one year later I wanna ask you. Is it now possible that i can compare a response with a external file? I tryed the solution with the variable but it´s not that nice. If the expResponse is not the curResponse I just get an FAILED but not where the probleme is. It would be good to compare a JSONFile with a response and exacly locate the failur. Further it would be great to seperate or selected the JSON compare. For example if I dont wanna compare the whole body it whould be great to have the possibility to unselect some keys and values (for example a Timestamp).

We are trying out and searching a Softwaresolution for our API-TESTING and Telerik is now under testing.

best regards

Kai
0
Oleg
Telerik team
answered on 17 Aug 2018, 08:52 AM
Hello Kai,

Thank you for reaching back to us.

Selecting an external file as a source for the expected value in verifications is not yet supported. Adding such a feature is still an option, but I cannot give an estimate about if and when we would raise its priority, so that we would include it in a future release.

Since version R2 2017 from May 30, 2017 though, Test Studio for APIs supports Coded Steps which allows users to achieve this and many more custom scenarios. You could use a coded step to read any value from a file and use it to perform all sorts of validations.

Also, you could achieve this kind of customized validation of the whole response JSON using JSON Schema (http://json-schema.org/). Coded steps in Test Studio for APIs allow adding references to external references, so you could use Json.NET Schema (https://www.newtonsoft.com/jsonschema) (or other .Net library for JSON Schema validation) in your coded steps to validate the full content of your responses. JSON Schema will let you customize your validation in order to expect specific values for some of the JSON properties, a range of valid values, or just a specific format for other properties (like Timestamp).

Regards,
Oleg
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Marco
Top achievements
Rank 1
Answers by
Oleg
Telerik team
Kai
Top achievements
Rank 1
Share this question
or