postmanpostman-collection-runnerpostman-testcasepostman-native-apppostman-mocks

How can I print the assertion with a value even if it get passed in Postman Api Testing


As a user, while executing the test cases created for the API Request, I'm expecting that it must show the value of the assertion even if the test cases pass.

For Example:

pm.test("User ID Should Exist", ()=>{

    value = bodyData.data.currentUser.id

    pm.expect(value).to.exist

    pm.environment.set("userID", value) 
})

When I run it, so it displays:

PASS - User ID Should Exist

How can I print the value of the User Id, even if the case passes on the test result section/tab?


Solution

  • You could do the following:

    value = bodyData.data.currentUser.id
    
    pm.test("User ID '" + value + "' should Exist", ()=>{
    
        pm.expect(value).to.exist
    
        pm.environment.set("userID", value) 
    })