-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(acceptance-test): New acceptance test when reactive-web or api-re…
…st component exists (#620) * fix: homologate api paths in entry point webflux with type router false or true * fix: acceptance test to basic web entry point * fix: update GetMapping value to /usecase/path * fix: set api rest acceptance test when module reactive-web or api-rest exist
- Loading branch information
1 parent
a1e3622
commit 27b16b1
Showing
12 changed files
with
149 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/resources/test/acceptance-test/api-rest/definition.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"folders": [ | ||
"deployment/{{acceptanceTestPath}}/src/test/java/{{packagePath}}/utils" | ||
], | ||
"files": { | ||
"test/acceptance-test/resources/logback-test.xml.mustache": "deployment/{{acceptanceTestPath}}/src/test/resources/logback-test.xml", | ||
"test/acceptance-test/api-rest/resources/karate-config.js.mustache": "deployment/{{acceptanceTestPath}}/src/test/resources/karate-config.js", | ||
"test/acceptance-test/api-rest/resources/myapp.feature.mustache": "deployment/{{acceptanceTestPath}}/src/test/resources/{{packagePath}}/myapp.feature", | ||
"test/acceptance-test/api-rest/readme.md.mustache": "deployment/{{acceptanceTestPath}}/README.md", | ||
"test/acceptance-test/TestParallel.java.mustache": "deployment/{{acceptanceTestPath}}/src/test/java/{{packagePath}}/TestParallel.java", | ||
"test/acceptance-test/utils/validator.test.utils.java.mustache": "deployment/{{acceptanceTestPath}}/src/test/java/{{packagePath}}/utils/ValidatorTestUtils.java", | ||
"test/acceptance-test/build.gradle.mustache": "deployment/{{acceptanceTestPath}}/build.gradle", | ||
"test/acceptance-test/settings.gradle.mustache": "deployment/{{acceptanceTestPath}}/settings.gradle" | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/main/resources/test/acceptance-test/api-rest/readme.md.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Proyecto Base de Karate para pruebas de integración en AcceptanceTest - REST, GraphQL, SOAP | ||
_Karate es una herramienta de código abierto que combina la automatización de pruebas de API, simulacros , pruebas de rendimiento e incluso la automatización de la interfaz de usuario en un marco único y unificado . La sintaxis BDD popularizada por Cucumber es un lenguaje neutro y fácil incluso para los no programadores. Las afirmaciones y los informes HTML están integrados y puede ejecutar pruebas en paralelo para aumentar la velocidad._ | ||
|
||
_Si está familiarizado con Cucumber / Gherkin, la gran diferencia aquí es que no necesita escribir código extra de "pegamento" o "definiciones de pasos" de Java._ | ||
|
||
**RECOMENDACION !!!**: Visitar la documentación oficial para obtener todas las ventajas de este potencial framework: https://github.com/intuit/karate | ||
## Comenzando | ||
|
||
### Instalación 🔧 | ||
|
||
**IMPORTANTE**: Este proyecto es una demo, proyecto base, para estructurar las pruebas de integración (AcceptanceTest) que se realizarán. Este proyecto es funcional yo consume la pet-store API en su versión 3 (https://petstore3.swagger.io/api/v3), sin embargo, a continuación te contamos que debes modificar y configurar para comenzar en tu contexto de aplicación con las pruebas: | ||
- Ir al karate-config.js y modificar la `urlBase` por la url o endpoint de tu aplicación. | ||
- Ir al karate-config.js y modificar la `oasUrl` por el path y nombre de la deficnicón open Api de la API a testear. | ||
- Ir a los archivos .feature (src>test>resources>{{package}}) agregar tus escenarios, métodos de prueba, aserciones, y todo lo necesario para tus pruebas en particular. | ||
|
||
Aquí se detalla la estructura que debe guiar las pruebas con Karate, es un ejemplo: | ||
|
||
``` | ||
src | ||
└── test | ||
├── java | ||
│ └── {{package}} | ||
│ ├── TestParallel.java | ||
│ └── utils | ||
│ └── ValidatorTestUtils.java | ||
└── resources | ||
├── {{package}} | ||
│ └── myapp.feature | ||
├── karate-config.js | ||
└── logback-test.xml | ||
``` | ||
|
||
- TestParallel -> Clase general en java que ejecuta los TESTS de karate en Paralelo y tambien genera el reporte de dichos TESTS en formato json que luego se convierte en reporte cucumber | ||
|
||
## Ejecutando las pruebas ⚙️ | ||
Este proyecto soporta ejecución por features tageados de manera independiente, como es el caso del feature demo.feature el cual tiene el tag @acceptanceTest. | ||
|
||
```gradle | ||
gradlew clean test "-Dkarate.options=--tags @acceptanceTest" -i | ||
``` | ||
|
||
De esta manera se ejecutaran todos los features con el tag @acceptanceTest. | ||
|
||
Por otra parte, si lo que se quiere es ejecutar todos los features almacenados en el proyecto bastará con ejecura el comando | ||
|
||
```gradle | ||
gradlew clean test -i | ||
``` |
19 changes: 19 additions & 0 deletions
19
src/main/resources/test/acceptance-test/api-rest/resources/karate-config.js.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function fn() { | ||
var env = karate.env || "dev"; | ||
var connectTimeout = karate.properties["connectTimeout"] || 45000; | ||
var baseUrl = | ||
karate.properties["baseUrl"] || | ||
"http://localhost:8080"; | ||
var config = { | ||
baseUrl | ||
}; | ||
|
||
karate.log("karate.env system property was: ", env); | ||
|
||
karate.configure('connectTimeout', 2000); | ||
karate.configure('readTimeout', 2000); | ||
karate.configure('ssl', true); | ||
return config; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/resources/test/acceptance-test/api-rest/resources/myapp.feature.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# We suggest to consulting the Karate Framework documentation: https://github.com/intuit/karate | ||
@acceptanceTest | ||
Feature: Here is the full description of the test suite to be run DEMO | ||
|
||
How ... | ||
Required ... | ||
To ... | ||
|
||
|
||
Background: | ||
# This property is taken from the karate-config.js file | ||
* url baseUrl | ||
|
||
# Reference | ||
# https://github.com/karatelabs/karate#request | ||
# https://github.com/karatelabs/karate#reading-files | ||
Scenario: This is the description of this scenario to be tested and its objective | ||
Given path '/api/usecase/path' | ||
When method get | ||
Then status 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters