Reading about frameworks is not enough. You need to build one. This exercise walks you through creating a complete API test framework from scratch. Use JSONPlaceholder (https://jsonplaceholder.typicode.com) as your target API.
Exercise 1: Project Setup
Create a new Maven project called api-test-framework
Add all dependencies to pom.xml: REST Assured, TestNG, Jackson, Allure
Create the full folder structure: config, base, pojo, endpoints, tests, utils
Create dev.properties with base.url=https://jsonplaceholder.typicode.com
Create ConfigReader.java and verify it loads the properties correctly
Exercise 2: Base Layer
Create BaseTest with @BeforeSuite and @BeforeClass methods
Set up RequestSpec with base URI, content type, and AllureRestAssured filter
Create BaseEndpoint with doGet, doPost, doPut, doDelete helper methods
Write a quick sanity test to verify the setup works: GET /posts should return 200
Exercise 3: POJOs
Create CreatePostRequest POJO with fields: title, body, userId
Create PostResponse POJO with fields: id, title, body, userId
Add @JsonIgnoreProperties(ignoreUnknown = true) on response POJO
Test serialization: create a POJO and print its JSON using ObjectMapper
Exercise 4: Endpoint + Test Classes
Create PostEndpoint with methods: getAll, getById, create, update, delete
Create PostTests with at least 5 tests: get all, get by ID, create, update, get invalid ID
Add a DataProvider with 3 different post data sets
Add TestNG groups: smoke, regression
Create testng.xml with smoke and regression configurations
Exercise 5: Reports and Execution
Add @Epic, @Feature, @Story, @Severity annotations to your tests
Verify that request/response details appear in the report for each test
Run only smoke tests: mvn test -Dgroups=smoke
Create staging.properties and run: mvn test -Denv=staging
Bonus Challenge
Add a UserEndpoint and UserTests class for the /users resource. Include nested POJO for the address object (street, suite, city, zipcode, geo). Add schema validation using matchesJsonSchemaInClasspath. Add a CommentEndpoint for /comments with query parameter support (postId). This gives you a 3-resource framework — exactly what you would describe in an interview.
Do not try to build everything at once. Follow the exercise order. Get each layer working before moving to the next. Config first. Then Base. Then one POJO. Then one endpoint. Then one test. Get one vertical slice working end to end. Then expand horizontally.
Key Point: Build the framework one layer at a time. Get a single vertical slice working (config to report) before expanding. Use JSONPlaceholder as your target API.