Multiple Tests per endpoint and testing for error conditions

Let’s say I have a simple GET endpoint that lists all values in a system, I’d want to test that we get back non-zero values with a 200 code.

But what if that endpoint had optional parameters like filtering, start/limit values for pagination etc? How could I run various tests to be sure that EACH parameter is working the way it should when used individually and together?

Similarly, what if I want to test my endpoint’s error responses? For example, what if i want to send it negative values for an index and be sure it sends me a 400?

Ideally, I’d like ALL of these things to be separate tests for a single GET endpoint but maybe I just don’t properly understand the flow of things in Postman and I need to make a completely separate item in my collection for each request I need to make?

Testing for 200 and 400 status codes cannot be run at the same time. As at least one would always fail.

At a minimum, these would need to be separate requests.

Same principal for optional parameters, these ought to be separate requests if you want to specifically test the existence or non-existence of those parameters. (So its the same endpoint, but separate requests).

When testing, you need to ensure the request returns the same response each time. (I’m not a fan of dynamic tests with shifting data as it increases the chances of false positives and incorrect results). You need to be in control of your test data.

You have the concept of collections, folders and requests. You may want to take a bit of time to think about how you want to structure this. For example, you may want to stick all of the requests for a certain endpoint in their own folder (or just the requests for optional parameters in a sub-folder).

Or maybe think about the collection as the test suite, the folder as the test case, and the individual requests as the test steps (which allows you to create end to end type tests - POST request, followed on by a GET, followed on by a DELETE).

Makes sense. Thanks!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.