Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

vutil provides a REST API to access database which can be used in validating the database state. With the help of this REST API, you may perform CRUD operations on various databases. As of now, following databases are supported:

  1. MySQL
  2. Postgres
  3. MongoDB
  4. MSSQL
  5. Oracle

We are also working on integration with other databases as well.  Please stay tuned.

Now, with the help of this API, one can perform the database validation after a test case is executed.

API Endpoint:

API Endpoint for DB Validation API is 

POST {{vutilBaseURL}}/execute/dbquery/{{connection}}

Here 

  1. {{vutilBaseURL}} is the variable, and the value is base URL of vutil server.
  2. {{connection}} is the path variable, and the value is the connection name of the database which is configured in config.json file.

And this API accepts a single body parameter "query" which can be either in STRING format or in JSON Object depending on the database vendor.

Steps:

Step by step guide to perform database validation:

...

Step 2: Execute your API test case and validate its response. e.g. for this guide, we are creating a contact with our sample contact API as follows:

Image Modified

Image Modified

Image Modified

Step 3: Now, to validate the database state, we need to write a separate test case in vREST. With the help of DB API provided by vutil, we can write the test case for db validation as follows:

  1. First create a test case with DB Validation API as follows:
    Image Modified
  2. Now, provide the connection name as follows:
    Image Modified
  3. Now, provide the request body for the DB Validation API:
    Image Modified
  4. Provide assertions as you provide for other test cases
    Image Modified
  5. And expected body as per your need.
    Image Modified

 That's it. In this way, you may validate the DB state.