API Automation RestAssured and Requests

Prasanth Karuppaiya

profile
API Automation RestAssured and Requests
profile
FREE
120 mins

API automation testing helps ensure the functionality, performance, and reliability of web services (REST APIs). It’s faster than UI testing and essential for validating business logic independently of the frontend.

  • Rest Assured (Java) is a powerful library built specifically for REST API testing. It integrates well with JUnit or TestNG and supports BDD style with Gherkin/Given-When-Then syntax.
  • Python Requests is a simple yet powerful HTTP library for sending requests and validating responses in a readable format. Ideal for lightweight, script-based API testing and perfect for beginners.

Topics to Cover

🔹 Common Topics (Java + Python)

  1. Introduction to API Testing
  • What is an API? Types (REST vs. SOAP)
  • Importance of API testing in software development
  1. HTTP Basics
  • Methods: GET, POST, PUT, DELETE, PATCH
  • Status codes and their meanings (200, 400, 404, 500, etc.)
  1. Understanding JSON and XML
  • Structure of request and response bodies
  • Tools to format and read (Postman, JSONLint)
  1. Making API Requests
  • URL, headers, body, query params
  • Authentication: Basic, Bearer Token, API Keys
  1. Assertions and Validations
  • Status code validation
  • Header and body assertions
  • JSON path and data extraction
  1. Chaining Requests
  • Using data from one request in the next
  • Dynamic payloads
  1. Negative Testing and Edge Cases
  • Invalid inputs, missing headers, expired tokens
  1. Request Logging and Debugging
  • Logging requests/responses
  • Tools like Postman for manual testing
  1. Environment Management
  • Base URLs, tokens, environments (dev/stage/prod)
  • Use of config files or environment variables

Rest Assured with Java

  1. Setup with Maven
  • Adding dependencies for Rest Assured, TestNG or JUnit
  • Project structure and folder setup
  1. Request Building
  • Fluent syntax: given().when().then()
  • Logging, request/response specs
  1. JSON Path Validation
  • Extracting fields, verifying nested values
  • Array handling
  1. Data-Driven Testing
  • Reading from Excel, JSON, or CSV
  • Using TestNG @DataProvider
  1. Reusable Methods and Framework Building
  • Utility classes
  • Base test classes and setup methods
  1. Report Generation
  • TestNG + Extent Reports integration

🐍 Python Requests for API Testing

  1. Installing Requests Library
  • pip install requests
  • Setting up virtual environments
  1. Making Requests with requests
  • requests.get(), post(), put(), delete()
  • Sending headers and payloads
  1. Using pytest for Automation
  • Writing test cases
  • Parametrized tests and fixtures
  1. Response Handling
  • response.status_code, json(), text, headers
  • Assertions with assert
  1. Extracting and Using Tokens
  • Token-based login, session reuse
  • Using requests.Session()
  1. Generating Reports
  • Allure or pytest-html reports

Let me know if you’d like:

  • Sample mini-projects or hands-on assignments
  • Cheat sheets or comparison tables
  • Real-world APIs (e.g., Reqres, Dummy JSON, OpenWeather) for practice
  • CI/CD or Postman collection export tips

Would you like me to prepare a printable curriculum or slides too?