{
"result": {
"code": 112,
"status": false,
"message": "Firstname can not be empty"
}
}
If you have a script, then tell me how do I show this message in ‘Test Results’
If this message is shown in ‘Test Result’, then I will not have to get validation
I want to show in the “Message” in “Test Results”
thank you
You could use something like this to check response data on a successful user registration:
pm.test("Successfully register a user", function () {
let jsonData = pm.response.json().result
pm.expect(jsonData.code).to.eql(200)
pm.expect(jsonData.status).to.be.true
pm.expect(jsonData.message).to.eql("User successfully registered")
})
It’s setting the results object in the response, as the jsonData variable. Then using the pm.expect() function, it’s checking the different values to ensure that these are returned correctly.
The pm.expect() function works with the [chaijs](https://www.chaijs.com/api/bdd/) assertion library that contains certain getters that chain together to construct assertions.
If you’re also looking to add a set of negative type tests to check that these failed cases are working as you expect them too, I would add new requests to the Collection and have these in a separate folder to the positive type tests.
Using the method above, you should be able to construct some tests to check for these different scenarios.
You could also look for things like:
Other different blank fields
All blank fields
Missing Keys
Additional Keys
The correct data types (swap string values for integers and vice versa)
null and undefined values
Different HTTP Methods and how these are handled (Is it just expecting you to POST something)
The actual response code returned (Should a successfully created user be a 200 or a 201)
etc.
This is not an exhaustive list but just some areas that you could create additional tests to check the data.
@danny-dainton My problem is solved by your reply
I was engaged in it for 2 days before asking question
i added if and else statement in your replay
Got what i want
I got the task at the postman Doing the same Right now i have more questions but
Thanks again