Ask a Question

SOAPUI Script Assertion: Identical values failing assert

New Contributor

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?



Community Hero

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.






if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta



@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())

New Contributor

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.

Showing results for 
Search instead for 
Did you mean: