Automated API testing framework using Karate (with built-in Cucumber/BDD engine), JUnit 5, and Maven.
| Technology | Version | Role |
|---|---|---|
| Java | 25 | Base language |
| Maven | 3.x | Dependency management and build |
| Karate | 1.4.1 | BDD framework for API testing |
| JUnit 5 | 5.10.2 | Test runner |
Karate includes the Cucumber engine internally — no additional Cucumber dependency is required.
The project follows a modular architecture organized by business domain, leveraging Karate's native capabilities for feature-to-feature calls and centralized configuration.
- No extra Java classes — all logic lives in
.featureand.jsfiles - Native reusability — common features are invoked with
call read() - Environment-based config —
karate-config.jscentralizes URLs and parameters - Decoupled test data — JSON/CSV files separated from test flow
- Scalable — adding a new domain = new folder, no changes to existing code
KarateTesting/
├── pom.xml
└── src/
└── test/
├── java/
│ └── runner/
│ └── TestRunner.java # JUnit 5 runner
└── resources/
├── karate-config.js # Environment configuration
├── common/
│ ├── auth.feature # Reusable authentication
│ └── helpers.js # Shared JS utility functions
├── users/
│ ├── users.feature # Users domain tests
│ └── data/
│ └── users-data.json # Test data
└── orders/
├── orders.feature # Orders domain tests
└── data/
└── orders-data.json # Test data
The environment is controlled with the karate.env variable. Defaults to dev.
| Environment | Base URL |
|---|---|
dev |
https://jsonplaceholder.typicode.com |
qa |
https://qa.api.example.com |
prod |
https://api.example.com |
mvn testmvn test -Dkarate.env=qa
mvn test -Dkarate.env=prod# Smoke tests only
mvn test -Dkarate.options="--tags @smoke"
# Regression tests only
mvn test -Dkarate.options="--tags @regression"Modify TestRunner.java to run testUsers() or testOrders() individually.
| Tag | Description |
|---|---|
@smoke |
Critical fast-validation tests |
@regression |
Full regression suite |
@ignore |
Utility features (not executed directly) |
Karate automatically generates HTML reports at:
target/karate-reports/karate-summary.html
- Create folder
src/test/resources/<domain>/ - Create
<domain>.featurewith the scenarios - Create
data/<domain>-data.jsonwith the test data - Add the method in
TestRunner.javaif a specific runner is needed
Scenario: Protected endpoint
* def auth = call read('../common/auth.feature') { username: 'user', password: 'pass' }
Given url baseUrl + '/secure-endpoint'
And header Authorization = 'Bearer ' + auth.authToken
When method GET
Then status 200