Forum Discussion
Format cell and take data as text like this - '176.98 and then call it. Else try this code:-
def data = 176.98 log.info new Double(data).round(2) assert new Double(result).round(2)==176.98
Hope it works for you.
Hi avidCoder,
Thank you so much for your reply, your solution '176.98 works. But in my spreadsheet (which I'm using for Data Source) there are so many columns which are using formulas. And if im doing the changes ('176.98 ) then formulas does not work.
Regrading your 2nd solution, I am not sure where to add this code as i am new to ReadyAPI (SoapUI Pro) so please provide my more details where i need to add the code in ReadyAPI. Do i need to add custom properties?
I will be very thankful to you :)
Thanks,
Amit
- avidCoder7 years agoSuper Contributor
yes.. got your issue.. In this case, You should go for second approach:-
def data = 176.98 log.info new Double(data).round(2) assert new Double(result).round(2)==176.98
Whatever column name (Output_loanTerm) data you want to fetch for assertion.
Read that column data using Java/Groovy code and convert it into double value rounded upto 2 digit.
If you want all the column data to be changed use for loop and implement the same.
- anagpal7 years agoOccasional Contributor
Hi avidCode,
Thnaks for your reply. I am little bit confuser here, i tried but assetion is always pass even for wrong values as well.
I need youe help to create the assetion: (we are using JSON as API request/response)
Scenarios: DataSource Testing
In Excel I have inputs as well ouputs, for one of scenario My excel (DataSource) output is :
( '${DataSource#Output_LoanTerm}' ) --> Value is 45
Now when i used Data Source for executing my test case API returns:
$['LoanTerm'] --> Value is 45.0I want to match ( '${DataSource#Output_LoanTerm}' ) = $['LoanTerm']
(45 = 45.0)Assertion failed, (due to .0). I tried the Assertion using Groovy script but no luck (may be i have no experience of Groovy Script). Can you please send me an example with above case.
Or can we use the JSONPath Asseretion for contect match as well, If yes please help, sorry as i have no knowledge of JSON :)
- anagpal7 years agoOccasional Contributor
Hi avidCode,
Thnaks for your reply. I am little bit confuser here, i tried but assetion is always pass even for wrong values as well.
I need youe help to create the assetion: (we are using JSON as API request/response)
Scenarios: DataSource Testing
In Excel I have inputs as well ouputs, for one of scenario My excel (DataSource) output is :
( '${DataSource#Output_LoanTerm}' ) --> Value is 45
Now when i used Data Source for executing my test case API returns:
$['LoanTerm'] --> Value is 45.0I want to match ( ${DataSource#Output_LoanTerm}) = $[LoanTerm]
(45 = 45.0)Assertion failed, (due to .0). I tried the Assertion using Groovy script but no luck (may be i have no experience of Groovy Script). Can you please send me an example with above case.
Or can we use the JSONPath Asseretion for contect match as well, If yes please help, sorry as i have no knowledge of JSON :)
- avidCoder7 years agoSuper Contributor
( '${DataSource#Output_LoanTerm}' ) --> Value is 45
After this convert it into double like the below code:-
def data = 45 def newData = new Double(data).round(2)
printf("${newData}")So, this will give you 45.0 as output and then
$['LoanTerm'] --> Value is 45.0
Match ( ${DataSource#Output_LoanTerm}) = $[LoanTerm]
Try this again and let me know.
If you are ok with answer. please don't forget to accpet as solution and kudos.
Related Content
- 8 years ago
Recent Discussions
- 14 hours ago
- 17 days ago