A RestAssured test automation framework for testing the AutomationExercise API endpoints.
This project tests various API endpoints from automationexercise.com using RestAssured, JUnit, and POJOs for clean, maintainable test code.
- Joshna Joshy - @joshnajoshy
- Matt Lewis - @parrais
- Uzo Ugochukwu - @uzougochukwu
- Shannel Feranand - @Shea-D-Coder
- Andi Pascale - @Andipascale7
- Ana Patricia Da Silva
- RestAssured - API testing framework
- JUnit 5 - Test runner and assertions
- Jackson - JSON serialisation/deserialisation
- Hamcrest - Assertion matchers
- Maven - Build and dependency management
| Endpoint | Method | Description |
|---|---|---|
/api/productsList |
GET | Retrieve all products |
/api/productsList |
POST | Invalid method test (negative scenario) |
/api/brandsList |
GET | Retrieve all brands |
/api/searchProduct |
POST | Search for products by keyword |
/api/createAccount |
POST | Register a new user account |
/api/getUserDetailByEmail |
GET | Fetch user details by email |
/api/deleteAccount |
DELETE | Delete a user account |
src/
├── main/
│ └── resources/
│ └── config.properties
└── test/
└── java/
└── com.sparta/
├── createaccount.restassured/
├── deleteaccount.restassured/
├── getallbrands.restassured/
├── getallproducts.restassured/
│ ├── pojos/
│ └── utils/
├── getuserdetail.restassured/
├── postallproducts.restassured/
└── searchproduct/
Each endpoint has its own package containing:
- Test classes
- POJOs for request/response mapping
- Shared utilities (Config, RequestSpecBuilder)
- Java 11 or higher
- Maven 3.6+
mvn clean testmvn test -Dtest=ListAllProductsTestsRight-click on any test class or method and select "Run"
- Create a new package under
src/test/java/com.sparta/for your endpoint - Create POJO classes in a
pojossubfolder to match the API response structure - Create your test class:
public class YourEndpointTest {
private static Response response;
@BeforeAll
static void setup() {
response = RestAssured
.given()
.baseUri(Config.getBaseUri())
.basePath("/api")
.contentType(ContentType.JSON)
.accept(ContentType.JSON)
.when()
.get("/yourEndpoint")
.then()
.extract().response();
}
@Test
void testStatusCode() {
MatcherAssert.assertThat(response.statusCode(), Matchers.is(200));
}
}The API returns JSON wrapped in HTML tags. Solution:
.expect().defaultParser(Parser.JSON)The API returns HTTP 200 for all responses but includes error codes in the response body. Tests validate both:
assertThat(response.statusCode(), is(200));
assertThat(responseBody.getResponseCode(), is(405));Some endpoints require multipart form data:
.contentType("multipart/form-data")
.multiPart("search_product", "tshirt")POJOs handle deeply nested structures:
{
"category": {
"usertype": {
"usertype": "Women"
},
"category": "Tops"
}
}- Inconsistent HTTP Status Codes: API returns 200 OK for error scenarios instead of appropriate error codes (e.g., 405 for unsupported methods)
- Irregular Product IDs: Gaps in the ID sequence and duplicate product names
- Content-Type Mismatch: API returns
text/htmlinstead ofapplication/json - Limited Documentation: Sparse API documentation required exploratory testing
- Add more negative test scenarios (invalid data, boundary testing)
- Test for duplicate records across endpoints
- Combine related operations (e.g., create account → get details → delete)
- Implement data-driven testing with multiple test datasets
- Add API performance tests
- Generate test reports using Allure or Extent Reports
This project follows a branching strategy:
main- Production-ready codedev- Development branchfeature/*- Individual feature branches
Base URI and other settings are stored in config.properties:
base.uri=https://automationexercise.com
base.path=/apiAccess via the Config utility class:
String baseUri = Config.getBaseUri();