Forum Discussion

mpw83's avatar
mpw83
Contributor
6 years ago

Process two different property values and set the results in another test case property

I have two test case level properties,  'Amount' and 'Interest' 

I want to add the values of these two properties and set the answer to another property called 'Payment' 

${#TestCase#Amount} ->  20000

${#TestCase#Interest} -> 200

${#TestCase#Payment} ->  20200

 

To do this I know I can use a groovy script but is it possible to directly do the calculation inside of the property?

like ..  ${#TestCase#Payment}  -> ${#TestCase#Amount} + ${#TestCase#Interest}  
If I call this property  ${#TestCase#Payment} inside in an assertion as the expected results, then It just compares with '20000 + 200' not the answer (20200).
Also, can we do this kind of calculations directly inside the assertion? 

 

  • You can use the script below as the property value for payment. You should be able to use that for an assertion as well, it just depends on what type of assertion you are doing.

     

    ${=import java.lang.Integer;def Payment = ${#TestCase#Amount} + ${#TestCase#Interest} }

     

  • You can use the script below as the property value for payment. You should be able to use that for an assertion as well, it just depends on what type of assertion you are doing.

     

    ${=import java.lang.Integer;def Payment = ${#TestCase#Amount} + ${#TestCase#Interest} }