Giter VIP home page Giter VIP logo

lippia-low-code-sample-project-1's Introduction

Lippia API Lowcode v1.0 @Unreleased

Crowdar Official Page Lippia Official Page

Lippia AC is a core level extension that allows us to automate api tests without the need to write code

Requirements

Getting Started

$ 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

Contents

  1. Variables
    I. Define
  2. Properties
    I. Lippia configuration file
    II. Basic properties file
  3. Requests
    I. Base URL
    II. Endpoint
    III. Headers
    IV. Body
    V. HTTP Method
  4. Assertions
    I. Status code II. JSON III.Schema
  5. Steps Glossary

Variables

I. Define

In order to define a variable and assign it with a constant value or a variable value use :

  * define [^\d]\S+ = \S+
  * define codigo = 7000

So that you need to call the previously defined variable, use double brackets :

For example

   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}}

alternatively you could use the value obtained from a response :

  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

Lippia Configuration file

(lippia.config)

├── 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.

For example

 -Denvironment=test

Enviroment Manager

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")

I.Base URL

The base url can be defined by the following step, it is simply to replace the regular expression /+S by the url :

For example

  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

Version 3.3.0.0 Version 3.3.0.1 or newer
Given base url env.base_url_rickAndMorty Given base url $(env.base_url_rickAndMorty)

II.Endpoint

You can easily replace the endpoint value in the regular expression of the "\S+" step :

   endpoint \S+

For example

  Given base url https://url-shortener-service.p.rapidapi.com
  And endpoint shorten

III.Headers

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+

For example

  And header Content-Type = application/json
  And header key = value

IV.Body

├── automation-reestructuracion-gateway
│   │   
│   ├── src
│   │   ├── main
│   ├── java
│   │     └── ...
│   ├── resources 
│   │     └── ...
│   ├── test
│   │     ├── resources
│   │     │   └── features
│   │     │   └── files
│   │     │   └── jsons
│   │               └──bodies
│   │               └── ...
│        

You can reference a json file created in the default location (jsons/bodies folder) :

####If the body doesn't need modification of any attribute or value, then this step is all that's required.

  Given body \S+

For example

Version 3.3.0.0 Version 3.3.0.1 or newer
Given body name_file.json Given body jsons/bodies/name_file.json

Or you can create a new folder inside it :

Version 3.3.0.0 Version 3.3.0.1 or newer
Given body new_folder/name_file.json Given body jsons/bodies/new_folder/name_file.json

I. SET

If you need to modify the value of any attribute in the body, you can use the Step "set value of key in body ".

We don't need the Step "body \S+" in our scenario because this step accesses the entire JSON file and also makes the necessary modifications.

In this case, it requires three parameters: the value to be assigned, the name of the attribute that will take the value of the first parameter, and the path with the name of the JSON file.

For example

     And set value 15 of key tags[1].id in body jsons/bodies/body2.json

II. DELETE

####Now, if you need to remove an attribute from the body, you can use Step "delete keyValue in body ", This one requires only two parameters: the attribute name and the name of the JSON file containing the request.

For example

       And delete keyValue tags[0].id in body jsons/bodies/body2.json

  • HTTP Method

The HTTP Methods supported by steps are : GET | POST | PUT | PATCH | DELETE

For example

 When execute method POST

  • Assertions

I. Status Code

The step to assert the HTTP response code is as follows :

     the status code should be <number>

For example

     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.

II. JSON

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 :

For example

  And response should be name = Rick Sanchez

Another way to reference it is by prepending "$." before the attribute name :

   And response should be $.status = Alive

The following step, allows for validations based on equality or containing a value that matches the response obtained based on the provided parameter.

  And verify the response [^\s].+ 'equals' [^\s].*
  And verify the response [^\s].+ 'contains' [^\s].*

For example

  And verify the response name 'contains' dog

Schemas

├── 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).

For example

Version 3.3.0.0 Version 3.3.0.1 or newer
And validate schema character.json And validate schema jsons/schemas/character.json

Steps Glossary

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>
verify the response ([^\\s].+) '(equals | contains)' ([^\\s].*) verificar la respuesta ([^\\s].+) '(equals | contains)' ([^\\s].*)

lippia-low-code-sample-project-1's People

Contributors

nicolasbacacoria avatar dkcrowdar avatar aryadna13 avatar maurospinelli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.