Lippia AC is a core level extension that allows us to automate api tests without the need to write code
$ git clone https://github.com/Crowdar/lippia-low-code-sample-project.git && cd "$(basename "$_" .git)"
Once the project is cloned and opened with your preferred ide, we can run the tests with the following command
$ mvn clean test -Dcucumber.tags=@Sample -Denvironment=default
- Variables
I. Define - Properties
I. [Lippia configuration file](#Lippia Configuration file)
II. Basic properties file - Requests
I. Base URL
II. Endpoint
III. Headers
IV. Body
V. [HTTP Method](#HTTP Method) - Assertions
I. [Status code](##I.Status Code) II. JSON - Steps Glossary
* define [^\d]\S+ = \S+
* define codigo = 7000
Given body body_request_1700.json
* define codigo = 7000
When execute method POST
Then the status code should be 400
And response should be $.code = {{codigo}}
Given body body_request_1700.json
When execute method POST
Then the status code should be 200
And response should be $.code = 7114
* define codigo = $.code
├── automation-reestructuracion-gateway
│ │
│ ├── src
│ │ ├── main
│ ├── java
│ │ └── ...
│ ├── resources
│ │ └── ...
│ ├── test
│ │ ├── resources
│ │ │ └── features
│ │ │ └── files
│ │ │ └── jsons
│ │ │ | └──bodies
│ │ │ | └── ...
│ │ │ └── queries
│ │ │ └── ...
│ │ │ └── extent.properties
│ │ │ └── lippia.conf
In this file you can specify the base url of the different environments, such as development, integration or testing :
environments {
default {
"base.url" = "https://www.by.default.com"
}
dev {
"base.url" = "https://www.dev-by.default.com"
}
test {
"base.url" = "https://www.test-by.default.com"
}
prod {
"base.url" = "https://www.?by.default.com"
}
}
The environments can be changed from the command line by referencing the respective environment by its name.
-Denvironment=test
To obtain data from the Environment manager we use the following method, in this case it is not allowed to obtain the base url
EnvironmentManager.getProperty("base.url")
####The base url can be defined by the following step, it is simply to replace the regular expression /+S by the url :
base url \S+
Given base url https://rickandmortyapi.com/api/
####Alternatively we can use the following notation, if we have defined the url in the lippia.conf file
Given base url env.base_url_rickAndMorty
endpoint \S+
Given base url https://url-shortener-service.p.rapidapi.com
And endpoint shorten
You can set a header just by defining the step and filling the key and the value as many times as you need to do it :
And header \S+ = \S+
And header Content-Type = application/json
And header key = value
├── automation-reestructuracion-gateway
│ │
│ ├── src
│ │ ├── main
│ ├── java
│ │ └── ...
│ ├── resources
│ │ └── ...
│ ├── test
│ │ ├── resources
│ │ │ └── features
│ │ │ └── files
│ │ │ └── jsons
│ │ └──bodies
│ │ └── ...
│
Given body \S+
Given body name_file.json
Given body new_folder/name_file.json
When execute method POST
the status code should be <number>
Then the status code should be 200
If the HTTP response code is anything other than what is expected, this assertion will result in the test failing.
You can make assertions on any attribute of the obtained response, whether it's integer, float, double, string, or boolean value by referencing it by its name :
And response should be name = Rick Sanchez
And response should be $.status = Alive
├── automation-reestructuracion-gateway
│ │
│ ├── src
│ │ ├── main
│ ├── java
│ │ └── ...
│ ├── resources
│ │ └── ...
│ ├── test
│ │ ├── resources
│ │ │ └── features
│ │ │ └── files
│ │ │ └── jsons
│ │ └── ...
│ │ └── ...
│ │ └── ...
│ │ └── ...
│ │ └── schemas
|
│
You can create a schema file with ".json" extension at the directory mentioned above (jsons/schemas folder).
And validate schema character.json
ENGLISH | SPANISH |
---|---|
add query parameter '<any>' = <any> | agregar parametro a la query '<any>' = <any> |
base url \S+ | base url \S+ |
body \S+ | body \S+ |
call \S+.feature[@:$]\S+ | invocar \S+.feature[@:$]\S+ |
create connection database '<any>' | crear conexion a la base de datos '<any>' |
define [^\d]\S+ = \S+ | definir [^\d]\S+ = \S+ |
delete keyValue <any> in body <any> | eliminar clave <any> en el body <any> |
endpoint \S+ | endpoint \S+ |
execute method GET l POST l PUT l PATCH l DELETE | ejecutar metodo GET l POST l PUT l PATCH l DELETE |
execute query '<any>' | ejecutar query '<any>' |
header \S+ = \S+ | header \S+ = \S+ |
And I save from result JSON the attribute on variable | guardo del resultado JSON el atributo en la variable <any> |
param \S+ = \S+ | param \S+ = \S+ |
response should be [^\s].+ = [^\s].* | la respuesta debe ser [^\s].+ = [^\s].* |
response should be [^\s].+ contains [^\s].* | la respuesta debe ser [^\s].+ contiene [^\s].* |
set value <any> of key <any> in body <any> | setear el valor <any> de la clave <any> en el body <any> |
the status code should be <number> | el status code debe ser <number> |
validate field '<any>' = <any> | validar el campo '<any>' = <any> |
validate schema <string> | validar schema <string> |