How to verify my value is Greater than or not?

Hi have an scenario, Were my API Requests also only 2500$ in a Request , If i send my Request more than 2500$ , How to verify the value in Tests and displays my error message ?

how to use the condition ? to verify and shows the error.

Please advise
My parameter
Amount : 2500
I have created a Variable as “amnt”
pm.expect(jsonData.data.bill).to.eql(amnt);

What if i pass 2600 in my request and how to verify in Tests and capture the error.

1 Like

Hello @Roshin_08 :wave:

You can try simple greater than symbol or above

 pm.test("Billing amount is less than 2500", function(){
            pm.expect(jsonData.data.bill<2500)
//or based on the req
//pm.expect(jsonData.data.bill<=2500)
});

Else chai below method works too.

 pm.test("Billing amount is less than 2500", function(){
            pm.expect(jsonData.data.bill).to.be.below(2500)
});

It’s better to go with the basic lesser than , greater than options :blush:

3 Likes

Here i have not hardcoded my Bill value , instead i have passed variable as “AMNTT”
pm.expect(jsonData.data.billResponse[0].bill).to.eql(amntt);

IN THIS CASE ABOVE METHODS WORKS LIKE < THAN OR TO.BE.BELOW
or we need to try something else ?? plz confirm it.

Yes it should work, please try both the ways and let me know if you have any issues :blush: