Ask a Question

SoapUI (Pro) > DataDriven > Message Content Assertion - How to handle decimal values

anagpal
Occasional Contributor

SoapUI (Pro) > DataDriven > Message Content Assertion - How to handle decimal values

I am using ReadyAPI(SoapUI Pro) for testing of a RestAPI. For TestData I'm using DataSource (DataDriven), where i am giving the Inputs (API Input) from excel. And to test the API response i am comparing the Output from Excel (Expected results are already in excel).
For that I am using Message Content Assertion (as its easy and im not much technical). Now problem is, In excel Expected Output is say 10.0 but when i use this excel field for assertion in SoapUI (Pro) it reads 10.0 > 10. But from API Response value is 10.0. So Assertion failed. I tried to handle it in excel but no luck.
 

So need help. In SoapUI we can handle it? (so that API response(10.0) match with Assertion value 10)

 

If its not possible using Message Content Assertion, then is it possible with JSONPath Existence Match ( I have not much knowledge of Json)

11 REPLIES 11
anagpal
Occasional Contributor

Assertion.jpg

 

I tried in JSONPath Asertion: Here in example, API Response - $['availableIncome'] = 1420.0

And in Expected result, I am checking the value from my excel (test Data expected output = 1420)

In expected result i added: 

def data = ${TestData-StandardLoan#Output_AvailableIncome} def newData = new Double(data).round(2)
printf("${newData}")

But it doen't work

avidCoder
Super Contributor

See, I don't have readyAPI installed in my system. Inside assertion, you need to use assert method.

 

def data = ${TestData-StandardLoan#Output_AvailableIncome} 
def newData = new Double(data).round(2)

assert $['availableIncome'] == newData

I thought you were using groovy script, that is why i gave you code snippet to verify using contains or equal method. 

cancel
Showing results for 
Search instead for 
Did you mean: