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