Search code examples
postmanpostman-collection-runner

How to show Assertion message in Postman?


I have this code in Postman where I put the message "Rates are close". how do you show that message, "Rates are close", to the run result on the section highlighted by the blue rectangle in the screenshot below?

pm.test("TestPricing",function(){ 
pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
 });

Screenshot of my collection Runner


Solution

  • Assertion message is thrown only when test fails not when it passes, green color shows test passed.

    Make test name more descriptive instead:

    pm.test(`Expect price to  be close to ${rateActualResult} with max delta difference of ± 0.01`,function(){ 
    pm.expect(RateFromData).to.closeTo(rateActualResult,0.01,"Rates are close");
     });
    

    Output:

    Pass:

    enter image description here

    Fail:

    enter image description here