API testing ensures backend services function correctly and reliably. Here's a step-by-step guide to mastering API testing using Postman and Rest Assured!
🔹 Common HTTP Status Codes & Meanings
- ✅ 200 OK – Request successful
- 🔄 201 Created – New resource created
- ⚠ 400 Bad Request – Invalid request syntax
- 🚫 401 Unauthorized – Authentication required
- ❌ 404 Not Found – Resource does not exist
- 💥 500 Internal Server Error – Unexpected server issue
🔗 Live APIs for Testing
- JSONPlaceholder – Fake API for testing
- ReqRes – User management testing
- HTTP Stat.us – Simulate HTTP status codes
🛠 Using Postman for API Testing
- Install Postman & create a new request.
- Select method (GET, POST, etc.) & enter the API URL.
- Add parameters or a request body if needed.
- Click "Send" and examine the response.
- Write assertions in the "Tests" tab:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
- Automate testing using Postman's Collection Runner.
🤖 Using Rest Assured for API Automation (Java)
📌 Maven Dependency (Add this to pom.xml):
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
📌 Basic Test Case:
import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
public class ApiTest {
public static void main(String[] args) {
given()
.when()
.get("https://jsonplaceholder.typicode.com/posts/1")
.then()
.statusCode(200)
.body("userId", equalTo(1));
}
}
🏆 Key API Testing Concepts
- Validate Response Codes & Body
- Header Validation & Authentication
- Negative Testing – Ensure the API handles invalid requests properly
- Data-Driven Testing – Use CSV/JSON inputs for test cases
📊 Advanced API Testing Techniques
- Mock APIs using Postman Mock Servers
- CI/CD Integration using Newman (Postman CLI)
- Automated Reporting with Extent Reports for Rest Assured
🚀 API testing is critical for software reliability. Whether using Postman for manual testing or Rest Assured for automation, mastering these skills helps deliver high-quality applications.


