This project automates API testing for the Simple Books API, utilizing Rest Assured, Java, Selenium, and Behavior Driven Development (BDD) with Cucumber. The automation framework supports various API testing scenarios including retrieving book information, submitting and managing orders, and testing API client authentication.
- Project Overview
- Technologies Used
- API Endpoints Covered
- Project Structure
- Setup Instructions
- Execution
- Cucumber Reports
- Contributing
- License
- Java: Programming language used for writing automation scripts.
- Rest Assured: Library for automating REST API requests.
- Selenium: For simulating browser actions if required during authentication.
- Cucumber: For Behavior Driven Testing (BDD) approach.
- Test NG: For executing test cases and assertions.
- Maven: Build tool used to manage project dependencies and plugins.
- Endpoint:
GET /status - Description: Returns the status of the API.
- Endpoint:
GET /books - Query Parameters:
type: fiction or non-fiction (optional)limit: number between 1 and 20 (optional)
- Description: Retrieves a list of available books.
- Endpoint:
GET /books/:bookId - Description: Fetches detailed information about a specific book.
- Endpoint:
POST /orders - Description: Submits a new order.
- Authentication: Requires an API token.
- Request Body:
{ "bookId": 1, "customerName": "John" }
- Endpoint:
GET /orders - Description: Retrieves a list of all submitted orders.
- Authentication: Requires an API token.
- Endpoint:
GET /orders/:orderId - Description: Fetches details about a specific order.
- Authentication: Requires an API token.
- Endpoint:
PATCH /orders/:orderId - Description: Updates an existing order.
- Authentication: Requires an API token.
- Request Body:
{ "customerName": "John" }
- Endpoint:
DELETE /orders/:orderId - Description: Deletes an existing order.
- Authentication: Requires an API token.
- Endpoint:
POST /api-clients - Description: Registers a new API client.
- Request Body:
{ "clientName": "Postman", "clientEmail": "example@example.com" }
src/
├── test/
├── resources/
│ └── features/
│ └── features.feature
│ └── java/
│ ├── helper/ # BDD feature files
│ └── BookClo.java
└── OrderClo.java
│ ├── runner/
└── RunCucumberTest.java # Cucumber test runner
│ └── steps/ # Step definitions for feature files
│ └── Steps.java # Pre/post execution hooks
features/: Holds the Gherkin (.feature) files that describe API test cases in BDD format.steps/: Contains the step definition classes where feature file steps are implemented.runner/: Cucumber runners to trigger BDD tests.helper/: Utility classes for token management, hooks, and other reusable logic.
- Java JDK 8+: Ensure Java is installed on your machine. Check by running
java -version. - Maven: Required for managing dependencies and building the project. Install and verify by running
mvn -version. - IDE (e.g., IntelliJ IDEA or Eclipse): Recommended for developing and running the project.
- Internet Connection: Required for fetching Maven dependencies.
-
Clone the repository:
git clone https://github.com/your-username/simple-books-api-automation.git cd simple-books-api-automation -
Install project dependencies:
mvn clean install
-
Configure environment variables for API token management if necessary (optional).
To run all tests using Cucumber, execute the following Maven command:
mvn testYou can run specific feature files by specifying the Cucumber tag:
mvn test -Dcucumber.options="--tags @orders"Cucumber generates HTML reports by default. After running the tests, you can find the generated reports in the target/cucumber-reports/ directory.
- HTML Report: Open
target/cucumber-reports/cucumber-html-reports/overview-features.htmlto view test results in the browser.
Feel free to submit issues or pull requests if you'd like to contribute to the project. Make sure to follow the coding standards and write tests for any new features or changes.
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
If you enjoy this content and want to support me, feel free to buy me a coffee
Happy testing! 🎉