cancel
Showing results for 
Search instead for 
Did you mean: 

Failing assertion, can't understand why or how to fix it?!

Occasional Contributor

Failing assertion, can't understand why or how to fix it?!

I am placing assertions against a JSON response, by right clicking the response and "Add Assertion > for Content"

 

Initially the assertion passes as expected. But items I created on Friday are failing on Monday. I've looked a dozen times and the fact is the response is 100% identical to to the expected assertion value. I've even used BeyondCompare to verify as well as Notepad++ to verify the text, carriage returns and line feeds are exactly the same. I don't understand how this can initially pass then not pass when the value returned as not changed.

 

I can't post the actual value due to complaince and security reasons so I will post an example response in hopes that this can be understood. The response is as follows (Note the CR/LF after Name):

RIVERSIDE-TN
SSN / ITIN: xxx-xx-xxxx
dba Example Company Name

 

 

5 REPLIES 5
Community Leader

Re: Failing assertion, can't understand why or how to fix it?!

Hi @Jason_S,

 

If you think that this response will never get changed, try adding contains assertion manually from the Bottom Assertion TAB and writing your expected over there.

 

Do Like and Accept if you find it as Solution.

 

Thanks,

Himanshu Tayal


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Occasional Contributor

Re: Failing assertion, can't understand why or how to fix it?!

I thought about that, but to be honest I really don't feel that's the appropriate answer.

 

In our business validating exact information is pretty crucial and I think using a contains would allow for additional information to technically pass. This information is likely to not change, but I cannot say with 100% certainty that it will never change. I would really like to understand why this is failing so that I, or someone, can correct this issue.

Community Leader

Re: Failing assertion, can't understand why or how to fix it?!

so in that case use jsonslurper for validating your response.

 

Go through groovy-slurping-json-in-script-assertions/

 

Do like and accept if you find it as solution.

 

Thanks,

Himanshu Tayal


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" Smiley Happy

Thanks and Regards,
Himanshu Tayal
Super Contributor

Re: Failing assertion, can't understand why or how to fix it?!

How about using regex?

 

Regular Visitor

Re: Failing assertion, can't understand why or how to fix it?!

I have exact same situation as Jason and would like to understand why it happens and is there any way to fix this problem.

 

New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors