đź§Ş Real-World API Testing Example

Imagine an e-commerce application.

The requirement says:

Customers should be able to add a product to their shopping cart.

You may have an API:

POST /cart/items

Request:

{
  "productId": 101,
  "quantity": 2
}

Now create different test scenarios.

Positive Scenarios

TC01: Add an available product.

TC02: Add multiple quantities.

TC03: Add a product after successful login.


Negative Scenarios

TC04: Add an invalid product ID.

TC05: Send quantity as zero.

TC06: Send a negative quantity.

TC07: Do not provide product ID.

TC08: Send an invalid authentication token.


Boundary Scenarios

If quantity allowed is 1–10:

0   → Negative
1   → Positive
2   → Positive
9   → Positive
10  → Positive
11  → Negative

This is exactly the kind of thinking you already use as a manual tester.


🔍 What Should You Validate in an API?

A good API test should validate more than just the status code.

Consider these areas:

1. Status Code

Is the HTTP status correct?

2. Response Body

Does the response contain the expected data?

3. Response Headers

Are the required headers present?

4. Data Types

Are values returned in the expected format?

5. Business Rules

Does the API follow the application’s business logic?

6. Error Messages

Are errors meaningful and appropriate?

7. Authentication

Can only authorized users access protected resources?

8. Authorization

Does the user have the correct permissions?

9. Response Time

Does the API respond within the expected time?

10. Data Integrity

Is the data correctly stored or updated?


⚠️ Common Mistakes Beginners Make

Mistake 1: Learning the Tool Before Understanding APIs

Do not start by memorizing Postman features.

First understand:

Request → API → Response

Then learn the tool.


Mistake 2: Checking Only Status Codes

A 200 OK response does not automatically mean the API is correct.

The response body and business logic can still contain defects.


Mistake 3: Ignoring Negative Scenarios

Real applications receive invalid data.

Always test:

Valid
Invalid
Empty
Null
Boundary
Unexpected
Unauthorized

Mistake 4: Jumping Directly Into Automation

Automation is valuable, but first understand how to test APIs manually.

A strong foundation makes automation much easier.


Mistake 5: Not Understanding Authentication

Many real-world APIs are protected.

Make authentication and authorization an important part of your learning.


Pages: 1 2 3 4 5 6 7 8

Leave a Reply

Your email address will not be published. Required fields are marked *