Postman 'or' Test Cases

(christian dabnor) #1

Hello there. I’m currently setting up a suite of test cases in Postman (first time using it, but it generally seems nice and easy so far, but have come across a slight issue. Due to the numbers and timescales we work with, there are acceptable variances due to rounding. Is there anyone who might be able to advise on how I can write my tests to allow this, please? My current test is:


But the result is an acceptable 540.69.

Thank you in advance.

(Geert) #2

Postman is using javascript for the code parts.
So you can check if the value is between two other value, set a variable to true/false and verify that.

 var margin = 0.05;
 var average = 540.65;
 var upperlimit = average + margin;
 var underlimit = average - margin;
 var result = false;
if(regularPayment < upperlimit && regularPayment > underlimit){
    result = true;

(christian dabnor) #3

That did the trick. Thank you.