Muhammad Uzair
Muhammad Uzair

Reputation: 30

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?

Upvotes: 1

Views: 652

Answers (1)

Christian Baumann
Christian Baumann

Reputation: 3434

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) 
}) 

Upvotes: 1

Related Questions