Skip to content

Commit 8809163

Browse files
committed
chore: readme update
1 parent 5f8a40e commit 8809163

File tree

1 file changed

+78
-59
lines changed

1 file changed

+78
-59
lines changed

README.md

Lines changed: 78 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
# Rest-Assured Complete Basic Example
2+
23
[![Actions Status](https://github.com/eliasnogueira/restassured-complete-basic-example/workflows/Build%20and%20Test/badge.svg)](https://github.com/eliasnogueira/restassured-complete-basic-example/actions)
34

4-
Don't forget to give this project a ⭐
5+
Remember to give this project a ⭐
56

67
* [Required Software](#required-software)
78
* [How to execute the tests](#how-to-execute-the-tests)
8-
* [Running the backend API](#running-the-backend-api)
9-
* [Running the test suites](#running-the-test-suites)
10-
* [Generating the test report](#generating-the-test-report)
9+
* [Running the backend API](#running-the-backend-api)
10+
* [Running the test suites](#running-the-test-suites)
11+
* [Generating the test report](#generating-the-test-report)
1112
* [About the Project Structure](#about-the-project-structure)
1213
* [Libraries](#libraries)
1314
* [Patterns applied](#patterns-applied)
1415
* [Pipeline](#pipeline)
1516
* [Do you want to help?](#do-you-want-to-help)
1617

17-
This project was created to start the initial steps with test automation for a REST API using Rest-Assured.
18-
It tests the API: [combined-credit-api](https://github.com/eliasnogueira/combined-credit-api)
18+
This project was created to start the initial steps with test automation for a REST API using RESTAssured.
19+
It tests the API: [credit-api](https://github.com/eliasnogueira/credit-api)
1920

2021
> :warning: **Disclaimer**
21-
>
22-
> This project has an educational objective and does not have the best practices that could be applied
2322
>
24-
> Some practices will help you to improve your test architecture, but the central point of this repository and
23+
> This project has an educational goal and does not have the best practices that could be applied
24+
>
25+
> Some practices will help you to improve your test architecture, but the central point of this repository and
2526
> demonstrate an example of running tests for API in a pipeline
26-
> some practices will help you to improve your test architecture,
27+
> some practices will help you to improve your test architecture,
2728
> but the central point of this repository and demonstrate an example of running tests for API in a pipeline
2829
2930
## Required software
30-
* Java JDK 24+
31-
* Maven installed and in your classpath
32-
* Clone/download the backend API [combined-credit-api](https://github.com/eliasnogueira/combined-credit-api)
33-
34-
> :notebook: **Note**
35-
>
36-
> You can use Java 17 if you want
3731

32+
* Java JDK 25
33+
* Clone/download the backend API [credit-api](https://github.com/eliasnogueira/credit-api)
3834

3935
## How to execute the tests
36+
4037
You can open each test class on `src\test\java` and execute all of them, but I recommend you run it by the
41-
command line. It enables us to run in different test execution strategies and, also in a pipeline, that is the repo purpose.
38+
command line. It enables us to run in different test execution strategies and, also in a pipeline, that is the repo
39+
purpose.
4240

4341
### Running the backend API
42+
4443
Please, before executing any tests, run the backend API.
45-
After cloning this project:
44+
After cloning the [credit-api](https://github.com/eliasnogueira/credit-api) project:
4645

4746
1. Navigate to the project folder using the Terminal / Command prompt
4847
2. Execute the following: `./mvnw spring-boot:run`
@@ -51,120 +50,136 @@ After cloning this project:
5150

5251
### Running the test suites
5352

54-
The test suites can be run directly by your IDE or by command line.
53+
The test suites can be run directly by your IDE or by the command line.
5554
If you run `./mvnw test` all the tests will execute because it's the regular Maven lifecycle to run all the tests.
5655

57-
To run different suites based on the groups defined for each test you must inform the property `-Dgroups` and the group names.
56+
To run different suites based on the groups defined for each test, you must inform the property `-Dgroups` and the group
57+
names.
5858
The example below shows how to run the test for each pipeline stage:
5959

60-
| pipeline stage | command |
61-
|--------------------|-------------------------------------|
62-
| health check tests | `./mvnw test -Dgroups="health"` |
63-
| contract tests | `./mvnw test -Dgroups="contract"` |
64-
| functional tests | `./mvnw test -Dgroups="functional"` |
65-
| e2e tests | `./mvnw test -Dgroups="e2e"` |
60+
| pipeline stage | command |
61+
|------------------|-------------------------------------|
62+
| contract tests | `./mvnw test -Dgroups="contract"` |
63+
| functional tests | `./mvnw test -Dgroups="functional"` |
64+
| e2e tests | `./mvnw test -Dgroups="e2e"` |
6665

6766
### Generating the test report
6867

6968
This project uses Allure Report to automatically generate the test report.
70-
There are some configuration to make it happen:
69+
There is some configuration to make it happen:
70+
7171
* aspectj configuration on `pom.xml` file
7272
* `allure.properties` file on `src/test/resources`
7373

7474
You can use the command line to generate it in two ways:
75+
7576
* `./mvnw allure:serve`: will open the HTML report into the browser
7677
* `./mvnw allure:report`: will generate the HTML port at `target/site/allure-maven-plugin` folder
7778

7879
## About the Project Structure
7980

8081
### src/main/java
8182

82-
#### test
83-
Base Test that sets the initial aspects to make the requests using RestAssured.
84-
It also has the configuration to deal with `BigDecimal` returns and SSL configuration.
85-
8683
#### client
84+
8785
Classes that do some actions in their endpoints. It's used my the `FullSimulationE2ETest` to demonstrate and e2e
8886
scenario.
8987

9088
#### commons
89+
9190
It contains a class where will format the URL expected when we create a new resource in the `simulation` endpoint.
9291
You can add any class that can be used in the project.
9392

9493
#### config
95-
The class `Configuration` is the connections between the property file `api.properties` located in `src/test/resources/`.
9694

97-
The `@Config.Sources` load the properties file and match the attributes with the `@Key`, so you automatically have the value.
95+
The class `Configuration` is the connections between the property file `api.properties` located in
96+
`src/test/resources/`.
97+
98+
The `@Config.Sources` load the properties file and match the attributes with the `@Key`, so you automatically have the
99+
value.
98100
You can see two sources.
99-
The first one will get the property values from the system (as environment variables or from the command line) in the case you want to change it, for example, in a pipeline.
101+
The first one will get the property values from the system (as environment variables or from the command line) in the
102+
case you want to change it, for example, in a pipeline.
100103
The second will load the `api.properties` file from the classpath.
104+
101105
```java
102106
@Config.Sources({
103-
"system:properties",
104-
"classpath:api.properties"})
107+
"system:properties",
108+
"classpath:api.properties"})
105109
```
106110

107111
The environment variable is read on the `ConfiguratorManager`.
108112
This class reduces the amount of code necessary to get any information on the properties file.
109113

110-
This strategy uses [Owner](https://matteobaccan.github.io/owner/) library
114+
This strategy uses the [Owner](https://matteobaccan.github.io/owner/) library
111115

112116
#### data
113117

118+
##### changeless
119+
120+
It contains a class having the data related to the test groups and constants.
121+
114122
##### factory
115-
Test Data Factory classes using [java-faker](https://github.com/DiUS/java-faker) to generate fake data and [Lombok] to
116-
create the objects using the Builder pattern.
123+
124+
Test Data Factory classes using [data-faker](https://www.datafaker.net/) to generate fake data.
117125

118126
In a few cases, there are custom data like:
119-
* the list of existent restrictions and simulations in the database
120-
* cpf generation
121-
* data generation returned by the API use
122127

123-
##### provider
124-
JUnit 5 Arguments to reduce the amount of code and maintenance for the functional tests on `SimulationsFunctionalTest`
128+
* the list of existent restrictions and simulations in the database
129+
* cpf generation
130+
* data generation returned by the API use
125131

126-
##### suite
127-
It contains a class having the data related to the test groups.
132+
##### provider
128133

129-
##### support
130-
Custom CPF (social security number) generator.
134+
JUnit 5 Arguments to reduce the amount of code and maintenance for the functional tests on `SimulationsFunctionalTest`
131135

132136
#### model
137+
133138
Model and Builder class to
134-
[mapping objects thought serialization and deserialization](https://github.com/rest-assured/rest-assured/wiki/Usage#object-mapping)
139+
[mapping objects thought serialization and deserialization](https://github.com/rest-assured/rest-assured/wiki/Usage#object-mapping)
135140
in use with Rest-Assured.
136141

137142
#### specs
143+
138144
Request and Response specifications used by the clients and e2e tests.
139145
The class `InitialStepsSpec` set the basePath, baseURI, and port for the custom specs.
140-
The classes `RestrictionsSpecs` and `SimulationsSpecs` contains the implementation of request and response specifications.
146+
The classes `RestrictionsSpecs` and `SimulationsSpecs` contains the implementation of request and response
147+
specifications.
141148

142149
### src/test/java
143150

144151
#### e2e
152+
145153
End-to-End test using both endpoints to simulate the user journey thought the API.
146154

147155
#### general
148-
Health check test to assure the endpoint is available.
156+
157+
Health check test to ensure the endpoint is available.
149158

150159
#### restrictions
160+
151161
Contract and Functional tests to the Restriction endpoint.
152162

153163
#### simulations
164+
154165
Contract and Functional tests to the Simulations endpoint
155166

156167
### src/test/resources
157-
It has a `schemas` folder with the JSON Schemas to enable Contract Testing using Rest-Assured. Also, the properties file to easily configure the API URI.
168+
169+
It has a `schemas` folder with the JSON Schemas to enable Contract Testing using Rest-Assured. Also, the properties file
170+
to easily configure the API URI.
158171

159172
## Libraries
160-
* [RestAssured](http://rest-assured.io/) library to test REST APIs
173+
174+
* [RESTAssured](http://rest-assured.io/) library to test REST APIs
161175
* [JUnit 5](https://junit.org/junit5/) to support the test creation
162176
* [Owner](https://matteobaccan.github.io/owner/) to manage the property files
163-
* [java-faker](https://github.com/DiUS/java-faker) to generate fake data
177+
* [data-faker](https://www.datafaker.net/) to generate fake data
164178
* [Log4J2](https://logging.apache.org/log4j/2.x/) as the logging strategy
165179
* [Allure Report](https://docs.qameta.io/allure/) as the testing report strategy
166180

167181
## Patterns applied
182+
168183
* Test Data Factory
169184
* Data Provider
170185
* Builder
@@ -174,23 +189,27 @@ It has a `schemas` folder with the JSON Schemas to enable Contract Testing using
174189
## Pipeline
175190

176191
This project uses [GitHub Actions](https://github.com/features/actions) to run the all the tests in a pipeline.
177-
You can find it at https://github.com/eliasnogueira/restassured-complete-basic-example/blob/master/.github/workflows/test-execution.yml
192+
You can find it
193+
at https://github.com/eliasnogueira/restassured-complete-basic-example/blob/master/.github/workflows/test-execution.yml
178194

179195
We have the following pipeline steps:
196+
180197
```
181-
build -> health check -> contract -> e2d -> funcional
198+
build -> contract -> e2e -> funcional
182199
```
183200

184-
Except the build, that is the traditional Maven build, the other stages has some parameters to determine the test type and the SUT (System Under Test).
201+
Except the build, that is the traditional Maven build, the other stages has some parameters to determine the test type
202+
and the SUT (System Under Test).
185203
The parameters are:
204+
186205
* `-Dgroups`: specify which test type will be executed
187206
* `-Dapi.base.uri`: specify a new base URI
188207
* `-Dapi.base.path`: specify a new base path
189208
* `-Dapi.port`: specify a new port
190209
* `-Dapi.health.context`: specify a new health context
191210

192211
All the parameters, except the `-Dgroups` are pointing to Heroku because we can't run it locally.
193-
It's a great example about how can you set different attribute values to run your tests.
212+
It's a great example of how you can set different attribute values to run your tests.
194213

195214
## Do you want to help?
196215

0 commit comments

Comments
 (0)