How anyanit/api-test-framework-sparta-academy-api- works
1. This repository is a test automation framework, not an application service. Its only runtime target is the external Sparta Academy REST API, which acts as the system under test.
2. The architecture is centered on a BDD testing flow:
- Gherkin scenarios in src/test/resources/features
- Java step definitions in src/test/java/com/sparta/steps
- A shared API utility layer in src/test/java/com/sparta/utils/ApiBuilder.java
- HTTP execution and assertions through RestAssured
3. CucumberRunnerTest is the main test entry point. It ties JUnit 5 to the Cucumber feature suite and is the class the README identifies as the way to run the framework end-to-end.
4. The step-definition layer is split by endpoint or behavior, which is the main functional boundary in the repo:
- login: /Auth/login
- courses: /api/Courses
- spartans: /api/Spartans
- CRUD variants for create, search, update, and delete
This keeps scenario steps thin and pushes reusable request/response logic into helpers.
5. ApiBuilder is the central service-object-style abstraction. It likely owns request setup, endpoint selection, headers/authentication, and response capture. In architectural terms, it is the seam between readable BDD tests and low-level HTTP calls.
6. The POJO package (Course, LoginRequest, Spartan, Stream) provides typed models for request payloads and response deserialization. This is the main data model boundary in the test stack, separating raw JSON from Java assertions.
7. Test data is externalized in src/test/resources/external:
- NewSpartan.json
- UpdatedSpartan.json
- MissingFirstNameSpartan.json
These files support happy-path and negative-path payload variation without embedding JSON inside step code.
8. config.properties is the environment/config boundary. It is used to parameterize the test run with values such as base URLs, credentials, or other environment-specific settings instead of hardcoding them in scenarios.
9. The validation strategy spans both positive and negative coverage. The framework checks status codes, response bodies, and schema-like expectations for successful requests, while also covering bad input, missing fields, invalid credentials, and unauthorized access.
10. The repo is built with Maven and organized as a test-only project under src/test, with no production source tree. CI is present via .github/workflows/maven-publish.yml, so the framework is intended to be executed and published through automated build infrastructure rather than deployed as an app.
11. The main technology boundaries are:
- Cucumber/Gherkin for scenario definition
- JUnit 5 for execution
- RestAssured for HTTP interaction
- Jackson / JSON Simple for JSON handling
- Maven for dependency/build management
This stack shapes the architecture around readable test specs, reusable request logic, and API-level assertions.
12. For an architecture diagram, the key flow is:
feature files → step definitions → ApiBuilder / POJOs / test resources → RestAssured → Sparta Academy API → assertions back in the test runner.
Main entry points: ApiBuilder.java ApiBuilder · features Feature Specs · CucumberRunnerTest.java Cucumber Runner · UserLoginSteps.java Login Steps
Components 18
Execution
Test runner and build entry points.
- Cucumber Runner · Main test entry point that executes the Cucumber suite end to end.
src/test/java/com/sparta/runner/CucumberRunnerTest.java - Maven Build · Build and dependency management for the test-only project.
pom.xml - CI Workflow · Automated workflow for running and publishing the test framework.
.github/workflows/maven-publish.yml
BDD Flow
Cucumber features and step definitions.
- Feature Specs · Readable BDD scenarios that define API behavior to verify.
src/test/resources/features - Login Steps · Step definitions for authentication and login behavior.
src/test/java/com/sparta/steps/UserLoginSteps.java - Course Steps · Step definitions for course search flows.
src/test/java/com/sparta/steps/SearchAllCoursesSteps.java - Course ID Steps · Step definitions for single-course lookup by id.
src/test/java/com/sparta/steps/SearchCourseWithIdSteps.java - Spartan Steps · Step definitions for listing and finding spartans.
src/test/java/com/sparta/steps/SearchAllSpartansSteps.java - Spartan ID Steps · Step definitions for single-spartan lookup by id.
src/test/java/com/sparta/steps/SearchSpartanWithIdSteps.java - Create Steps · Step definitions for creating spartans.
src/test/java/com/sparta/steps/CreateNewSpartanSteps.java - Update Steps · Step definitions for updating spartans.
src/test/java/com/sparta/steps/UpdateSpartanSteps.java - Delete Steps · Step definitions for deleting spartans.
src/test/java/com/sparta/steps/DeleteSpartanSteps.java
HTTP Core
Reusable API request and assertion layer.
- ApiBuilder · Shared abstraction for request setup, endpoint selection, auth, execution, and response capture.
src/test/java/com/sparta/utils/ApiBuilder.java - RestAssured · Library used to issue API requests and inspect responses.
Test Data
Typed payload models and external JSON fixtures.
- Typed Models · Java request/response models used for serialization and assertions.
src/test/java/com/sparta/pojos - JSON Fixtures · Externalized request bodies for create and update scenarios.
src/test/resources/external
External Runtime
System under test and environment configuration.
- Config Props · External configuration for base URLs, credentials, and run-time settings.
src/test/resources/config.properties - Sparta API · External REST API exercised by the framework.
Connections 27
- CI Workflow → Maven Build: runs · CI executes the Maven build and test lifecycle.
- Maven Build → Cucumber Runner: executes · Maven/JUnit launch the Cucumber runner.
- Cucumber Runner → Feature Specs: loads · Runner discovers and executes feature specifications.
- Feature Specs → Login Steps: binds · Scenarios map to authentication step definitions.
- Feature Specs → Course Steps: binds · Scenarios map to course listing steps.
- Feature Specs → Course ID Steps: binds · Scenarios map to course-by-id steps.
- Feature Specs → Spartan Steps: binds · Scenarios map to spartan listing steps.
- Feature Specs → Spartan ID Steps: binds · Scenarios map to spartan-by-id steps.
- Feature Specs → Create Steps: binds · Scenarios map to create-spartan steps.
- Feature Specs → Update Steps: binds · Scenarios map to update-spartan steps.
- Feature Specs → Delete Steps: binds · Scenarios map to delete-spartan steps.
- Login Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Course Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Course ID Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Spartan Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Spartan ID Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Create Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Update Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- Delete Steps → ApiBuilder: uses · Steps delegate HTTP work to the shared builder.
- ApiBuilder → RestAssured: drives · Builder wraps the underlying HTTP execution library.
- ApiBuilder → Config Props: reads · Builder and tests consume environment settings from properties.
- ApiBuilder → Typed Models: serializes · Builder works with typed payloads and response models.
- Create Steps → JSON Fixtures: loads · Create scenarios source payload variants from external JSON.
- Update Steps → JSON Fixtures: loads · Update scenarios source payload variants from external JSON.
- ApiBuilder → Sparta API: calls · HTTP requests are executed against the external Sparta Academy API.
- Login Steps → Typed Models: uses · Login payloads are represented with typed request models.
- Cucumber Runner → Sparta API: verifies · The end-to-end test run asserts behavior against the system under test.