You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| contract tests |`./mvnw test -Dgroups="contract"`|
63
+
| functional tests |`./mvnw test -Dgroups="functional"`|
64
+
| e2e tests |`./mvnw test -Dgroups="e2e"`|
66
65
67
66
### Generating the test report
68
67
69
68
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
+
71
71
* aspectj configuration on `pom.xml` file
72
72
*`allure.properties` file on `src/test/resources`
73
73
74
74
You can use the command line to generate it in two ways:
75
+
75
76
*`./mvnw allure:serve`: will open the HTML report into the browser
76
77
*`./mvnw allure:report`: will generate the HTML port at `target/site/allure-maven-plugin` folder
77
78
78
79
## About the Project Structure
79
80
80
81
### src/main/java
81
82
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
-
86
83
#### client
84
+
87
85
Classes that do some actions in their endpoints. It's used my the `FullSimulationE2ETest` to demonstrate and e2e
88
86
scenario.
89
87
90
88
#### commons
89
+
91
90
It contains a class where will format the URL expected when we create a new resource in the `simulation` endpoint.
92
91
You can add any class that can be used in the project.
93
92
94
93
#### config
95
-
The class `Configuration` is the connections between the property file `api.properties` located in `src/test/resources/`.
96
94
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.
98
100
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.
100
103
The second will load the `api.properties` file from the classpath.
104
+
101
105
```java
102
106
@Config.Sources({
103
-
"system:properties",
104
-
"classpath:api.properties"})
107
+
"system:properties",
108
+
"classpath:api.properties"})
105
109
```
106
110
107
111
The environment variable is read on the `ConfiguratorManager`.
108
112
This class reduces the amount of code necessary to get any information on the properties file.
109
113
110
-
This strategy uses [Owner](https://matteobaccan.github.io/owner/) library
114
+
This strategy uses the [Owner](https://matteobaccan.github.io/owner/) library
111
115
112
116
#### data
113
117
118
+
##### changeless
119
+
120
+
It contains a class having the data related to the test groups and constants.
121
+
114
122
##### 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.
117
125
118
126
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
122
127
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
125
131
126
-
##### suite
127
-
It contains a class having the data related to the test groups.
132
+
##### provider
128
133
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`
131
135
132
136
#### model
137
+
133
138
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)
135
140
in use with Rest-Assured.
136
141
137
142
#### specs
143
+
138
144
Request and Response specifications used by the clients and e2e tests.
139
145
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.
141
148
142
149
### src/test/java
143
150
144
151
#### e2e
152
+
145
153
End-to-End test using both endpoints to simulate the user journey thought the API.
146
154
147
155
#### general
148
-
Health check test to assure the endpoint is available.
156
+
157
+
Health check test to ensure the endpoint is available.
149
158
150
159
#### restrictions
160
+
151
161
Contract and Functional tests to the Restriction endpoint.
152
162
153
163
#### simulations
164
+
154
165
Contract and Functional tests to the Simulations endpoint
155
166
156
167
### 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.
158
171
159
172
## Libraries
160
-
*[RestAssured](http://rest-assured.io/) library to test REST APIs
173
+
174
+
*[RESTAssured](http://rest-assured.io/) library to test REST APIs
161
175
*[JUnit 5](https://junit.org/junit5/) to support the test creation
162
176
*[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
164
178
*[Log4J2](https://logging.apache.org/log4j/2.x/) as the logging strategy
165
179
*[Allure Report](https://docs.qameta.io/allure/) as the testing report strategy
166
180
167
181
## Patterns applied
182
+
168
183
* Test Data Factory
169
184
* Data Provider
170
185
* Builder
@@ -174,23 +189,27 @@ It has a `schemas` folder with the JSON Schemas to enable Contract Testing using
174
189
## Pipeline
175
190
176
191
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
178
194
179
195
We have the following pipeline steps:
196
+
180
197
```
181
-
build -> health check -> contract -> e2d -> funcional
198
+
build -> contract -> e2e -> funcional
182
199
```
183
200
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).
185
203
The parameters are:
204
+
186
205
*`-Dgroups`: specify which test type will be executed
187
206
*`-Dapi.base.uri`: specify a new base URI
188
207
*`-Dapi.base.path`: specify a new base path
189
208
*`-Dapi.port`: specify a new port
190
209
*`-Dapi.health.context`: specify a new health context
191
210
192
211
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.
0 commit comments