SOAPUI Script Assertion: Identical values failing assert
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SOAPUI Script Assertion: Identical values failing assert
While trying to test a REST API I am trying to compare a value in a response with a previous value stored in a separate testCase. Using script assertion, I am getting the proper values and they are identical, but when I try to match them using an assert it fails.
Any clue as to why this is happening and how I can resolve it?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey @mehdihs
so just to be clear, the stl_id attribute (jsonpath $.data.stl_id) in response is being reported identical to the property value saved from a previous testcase identified by sellPrgSTLID, is that right?
have you made sure you haven't got any invisible space chars at the end of either the saved property or the stl_id value in response? Cos that would generate the same behaviour as what you're reporting.
ta
rich
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
@richiemakes a good point about potential trailing spaces. Beyond this, are sure they are the same type? For example 12345 is not equal to "12345". You could try casting both values to a string or integer and then comparing. E.g. assertEquals leftSide.toString().trim() == rightSide.toString().trim().
Also, you might want to read further into Groovy/Java string comparators. I quite often use the .equals() and .contains() methods on a string. Example assert leftSide.toString().equals(rightSide.toString()) or assert leftSide.toString().contains(rightSide.toString())
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. I tried your solution and the assert passed. It was an issue of the values being of different types. Just trimming did not work.
