Every production API framework follows the same layered architecture. Like a building — foundation at the bottom, rooms on top. Each layer has one job. Each layer only talks to the layer directly below it. No skipping.
| Layer | Responsibility | Key Classes/Files |
|---|---|---|
| Config | Store environment-specific settings. Base URL, credentials, timeouts. | config.properties, ConfigReader.java |
| Base | Set up common request spec — headers, content type, base URI, logging. | BaseTest.java, BaseEndpoint.java |
| POJOs | Java objects that map to JSON request/response bodies. | UserRequest.java, UserResponse.java |
| Endpoints | Wrap REST Assured calls. One class per API resource. | UserEndpoint.java, AccountEndpoint.java |
| Tests | Business logic assertions. What to test, not how to call the API. | UserTests.java, AccountTests.java |
| Reports | Capture request/response details for every test. | Allure annotations, AllureRestAssured filter |
The moment a test class calls given().baseUri("http://...").when().get("/users") directly — your framework discipline is broken. Tests should only call endpoint methods like userEndpoint.getAll(). If you see raw REST Assured in test classes, refactor immediately.
Think of ordering food at a restaurant. You (Test) tell the waiter (Endpoint) what you want. The waiter tells the kitchen (REST Assured + Base). The kitchen uses ingredients from the pantry (Config + POJOs). You never walk into the kitchen yourself. That is the separation.
Key Point: The 6 layers — Config, Base, POJOs, Endpoints, Tests, Reports — each have one job. Tests never touch REST Assured directly. Endpoints never hardcode URLs. Config is the single source of truth for environment settings.
Q: Describe the architecture of your API test automation framework.
A: Our framework has 6 layers. Config layer reads environment-specific properties like base URL and credentials from config.properties using a ConfigReader class. Base layer has BaseTest which sets up a common RequestSpecification — base URI, content type, headers, and logging. POJO layer has Java classes that model request and response bodies using Jackson annotations. Endpoint layer wraps REST Assured calls — one class per API resource (UserEndpoint, AccountEndpoint), each method represents one API operation. Test layer has TestNG test classes that use endpoint methods and assert business logic. Report layer uses Allure with the AllureRestAssured filter to capture every request and response automatically. Each layer only depends on the one below it.
Key Point: A production API framework has 6 layers: Config, Base, POJOs, Endpoints, Tests, Reports. Each layer has one job. Tests never touch REST Assured directly.