Forum Discussion
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.
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.0
I 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.
- anagpal7 years agoOccasional Contributor
Hi,
I tired but no luck :(
So where to add this code:
def data = 45 def newData = new Double(data).round(2)
printf("${newData}")In excel or Assetion window (JSON Path Expression)
- anagpal7 years agoOccasional Contributor
Hi,
I tired but no luck :(
So where to add this code:
def data = 45 def newData = new Double(data).round(2)
printf("${newData}")In excel or Assetion JSON Path Expression
- avidCoder7 years agoSuper Contributor
Hey, you need to add this code where erver you are trying to do assertion.
And also if you are using Ready API tool use, log.info to print anything.
Related Content
- 8 years ago
Recent Discussions
- 22 days ago