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:
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 for DB Validation API is
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.
Step by step guide to perform database validation:
Step 1: Configure connection details in vutil
First you need to configure database connection details in config.json file. If you have not created a config.json file, then create one by copying the config.sample.json into config.json file and provide the connection details as per the samples provided.
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:
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:
That's it. In this way, you may validate the DB state.