Skip to content

Commit f8ecb96

Browse files
Marta KravchukMarta Kravchuk
authored andcommitted
update README
1 parent 7fbeada commit f8ecb96

1 file changed

Lines changed: 46 additions & 40 deletions

File tree

README.md

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,55 @@
1-
# API Automation Demo Project: Testing Online Bookstore
1+
![Java](https://img.shields.io/badge/java-white?style=for-the-badge&logo=openjdk&logoSize=auto&color=%23e69138&cacheSeconds=3600&link=https%3A%2F%2Fwww.oracle.com%2Fjava%2F)
2+
![JavaScript](https://img.shields.io/badge/JavaScript-white?style=for-the-badge&logo=javascript&logoSize=auto&color=%23e69138&cacheSeconds=3600)
3+
![Maven](https://img.shields.io/badge/maven-white?style=for-the-badge&logo=apachemaven&logoSize=auto&color=%23cc0000&cacheSeconds=3600&link=https%3A%2F%2Fmaven.apache.org)
4+
![RestAssured](https://img.shields.io/badge/RestAssured-white?style=for-the-badge&logoSize=auto&color=%236aa84f&cacheSeconds=3600&link=https%3A%2F%2Frest-assured.io)
5+
![TestNG](https://img.shields.io/badge/testng-white?style=for-the-badge&logoSize=auto&color=%233d85c6&cacheSeconds=3600&link=https%3A%2F%2Ftestng.org)
6+
![Allure Report](https://img.shields.io/badge/allure-white?style=for-the-badge&logoSize=auto&color=%23f1c232&cacheSeconds=3600&link=https%3A%2F%2Fallurereport.org)
27

3-
This framework automates the testing of a bookstore's **RESTful API**.
4-
A completely custom REST API has been developed using **Express.js**, referencing the structure for API endpoints from the demo testing service [FakeRestApi.Web V1](https://fakerestapi.azurewebsites.net/) which operates in static mode.
8+
# API Automation Demo Project: REST Assured & Express.js (Node.js)
9+
10+
This framework automates the testing of a bookstore's **RESTful API**. A completely custom REST API has been developed using **Express.js**, referencing the structure for API endpoints from the demo testing service [FakeRestApi.Web V1](https://fakerestapi.azurewebsites.net/) which operates in static mode.
511
This project aims to create a maintainable test framework, implement reusable code, handle various scenarios, generate informative test reports, and establish a CI/CD pipeline for continuous integration.
612

7-
Below are the tools and technologies used in this framework:<br/>
8-
- **Programming Language**: Java
13+
This API test automation framework utilizes TestNG and REST Assured, managed with Maven for building, and generates clear, insightful reports using Allure Report.
14+
It provides a set of predefined test cases to ensure bookstore API functions behave as expected.
15+
16+
17+
### ⚙️ Tech Stack
18+
- **Programming Languages**: Java, JavaScript
919
- **Testing Framework**: TestNG
1020
- **API Testing Library**: REST Assured
1121
- **Reporting**: Allure Report
1222
- **Build Tool**: Maven
1323
- **CI/CD**: GitHub Actions
1424
- **Backend API**: Express.js (Node.js)
1525

26+
### ✅ Requirements
27+
Requires **Java 22**, **Maven 3.9.x**, and **Allure Report 2.33.x** to be installed and properly configured on your local machine.<br/>
28+
1629
## Table of Contents
17-
1. [Setup local machine](#one)
18-
* [Setting up REST API using Express.js](#two)
19-
2. [Framework Overview](#three)
20-
3. [Framework Structure](#four)
21-
4. [Creating API Test Scenarios](#five)
22-
5. [API Test Execution](#six)
23-
6. [Generate Allure REST Assured Report](#seven)
24-
7. [CI/CD Pipeline with GitHub Actions](#eight)
30+
1. [Setting up REST API using Express.js](#one)
31+
2. [Framework Structure](#two)
32+
3. [Creating API Test Scenarios](#three)
33+
4. [API Test Execution](#four)
34+
5. [Generate Allure REST Assured Report](#five)
35+
6. [CI/CD Pipeline with GitHub Actions](#six)
2536

2637
<a id="one"></a>
27-
## 1. Setup local machine
28-
#### This guide assumes the following:
29-
* Have **Maven** and **Java 22** installed.<br/>
30-
31-
<a id="two"></a>
32-
### Setting up REST API using Express.js
38+
## 1. Setting up REST API using Express.js
3339
The REST API, built with **Express.js**, is already set up and configured for immediate use.
3440
The following steps provide details for understanding the setup process and exploring the existing configuration:<br/>
3541

36-
_**Step 1.** Project Initialization:_<br/>
42+
### Step 1. Project Initialization:
3743
A new project directory (`api-bookstore/`) was created, and `npm init -y` command was used to initialize the project.
3844
This generates a `package.json` file, which is essential for managing project dependencies.
3945

40-
_**Step 2.** Installing Dependencies:_<br/>
46+
### Step 2. Installing Dependencies:
4147
The following dependencies were installed by running `npm install express body-parser nodemon`:
4248
* `express` - the Express.js framework for building the API.
4349
* `body-parser` - middleware for parsing request bodies, allowing easy access to data sent in POST and PUT requests.
4450
* `nodemon` - utility that automatically restarts the server upon file changes, enhancing the development experience.
4551

46-
_**Step 3.** Creating `server.js`_<br/>
52+
### Step 3. Creating `server.js`:
4753
The core logic of the API resides in the `server.js` file. It handles routing, request processing, and data management, performing the following key tasks:
4854
* Loads necessary libraries like Express.js for routing and request handling, and middleware for parsing incoming data.
4955
* Creates an instance of the Express application, which serves as the foundation for the API.
@@ -54,7 +60,7 @@ The core logic of the API resides in the `server.js` file. It handles routing, r
5460

5561
You can explore the `server.js` file in the `api-bookstore/` directory for more details on the API implementation.
5662

57-
_**Step 4.** Configuring `package.json`_<br/>
63+
### Step 4. Configuring `package.json`:
5864
The `package.json` is an important file in Node.js projects. It has several critical functions:
5965
* Contains **metadata** about the project, such as name, version, description, author, license, etc.
6066
* Indicates **dependencies** which other packages (libraries) your project depends on. The `npm` uses this information to install the necessary packages.
@@ -65,18 +71,14 @@ You can explore the `package.json` file in the `api-bookstore/` directory for mo
6571
It is used to define dependencies (**express**, **body-parser**, **nodemon**) and scripts (`start`, `dev`).
6672
This helps to quickly set up the project by simply running `npm install`.
6773

68-
_**Step 5.** Run server_<br/>
74+
### Step 5. Run server:
6975
To start the server in development mode, use the following command `npm run dev`.
7076
This command leverages `nodemon` to automatically restart the server whenever file changes are detected.
7177
Upon successful startup, you should see a message similar to _"Server is running on port 3000"_ in your terminal, confirming that the API is active and listening for requests.
7278

73-
<a id="three"></a>
74-
## 2. Framework Overview
75-
This API test automation framework utilizes TestNG and REST Assured, managed with Maven for building, and generates clear, insightful reports using Allure Report.
76-
It provides a set of predefined test cases to ensure bookstore API functions behave as expected.
7779

78-
<a id="four"></a>
79-
## 3. Framework Structure
80+
<a id="two"></a>
81+
## 2. Framework Structure
8082
The framework's architecture is built on a structured directory organization to ensure scalability and maintainability:<br/>
8183
```
8284
|--online-bookstoore-frmk/
@@ -106,8 +108,9 @@ The framework's architecture is built on a structured directory organization to
106108
3. The `pom.xml` file in the root directory contains project information and configuration details for **Maven**, used to manage dependencies and build the project.
107109
4. The `testng.xml` file is a configuration file used by the **TestNG** testing framework to organize and define the test suite.
108110

109-
<a id="five"></a>
110-
## 4. Creating API Test Scenarios
111+
112+
<a id="three"></a>
113+
## 3. Creating API Test Scenarios
111114
Creating API test scenarios involves defining test data and expected API behavior.<br/>
112115

113116
**Steps to Build API Test Scenarios:**
@@ -116,8 +119,9 @@ Creating API test scenarios involves defining test data and expected API behavio
116119
3. _Define Response Specifications:_ create expected response specifications using REST Assured to validate API responses.
117120
4. _Execute API Requests:_ perform API requests using the generated test data and validate responses against the defined specifications.
118121

119-
<a id="six"></a>
120-
## 5. API Test Execution
122+
123+
<a id="four"></a>
124+
## 4. API Test Execution
121125
This project uses **Maven** for dependency management and build automation. The base URL for the API tests can be configured by creating a hidden `.env` file and defining the `BASE_URL` parameter.
122126
The default value is `http://localhost:3000/api/v1/`, but this setting can be modified directly within the `server.js` file.<br/>
123127

@@ -137,8 +141,9 @@ mvn test -Dtest={String}
137141
_Parameters:_<br/>
138142
`-Dtest={String}` - name of Test class.<br/>
139143

140-
<a id="seven"></a>
141-
## 6. Generate Allure REST Assured Report
144+
145+
<a id="five"></a>
146+
## 5. Generate Allure REST Assured Report
142147
Before running tests, it's crucial to clean up any existing test results and reports. This ensures that your report accurately reflects the most recent test run.
143148
Use the following command to remove the `allure-report` and `allure-results` directories:
144149
```bash
@@ -168,13 +173,14 @@ allure serve
168173
```
169174
This command starts a local web server and automatically opens the generated report in your default browser.
170175

171-
##### Allure Report Overview
172-
An example of the generated Allure report looks like this:
176+
### Allure Report Overview:
177+
An example of the generated Allure report looks like this:<br/>
173178
![RestAssured_Allure Overview](https://github.com/user-attachments/assets/8f94e005-87b1-49ba-b851-2546068aeba9)
174179
![RestAssured_Allure](https://github.com/user-attachments/assets/154153b0-284d-4080-8c84-3fdc951751a7)
175180

176-
<a id="eight"></a>
177-
## 7. CI/CD Pipeline with GitHub Actions
181+
182+
<a id="six"></a>
183+
## 6. CI/CD Pipeline with GitHub Actions
178184
This project utilizes a CI/CD pipeline configured using GitHub Actions. The pipeline automates the testing process, ensuring that every code change is thoroughly validated.
179185
The configuration file for the workflow is located at `.github/workflows/ci.yml`.
180186

0 commit comments

Comments
 (0)