visit
Swagger Files (aka OpenAPI Specification) is the most popular way for documenting API specifications and Excel sheet provides an easy and simple way of writing structured data. Anybody can write data in excel sheet irrespective of their programming skills. Introducing (An enterprise ready application for Automated API Testing), which combines the power of both to make your API Testing experience more seamless. The approach is also known as Data Driven Testing.
Data Driven testing is an approach in which test data is written separately from the test logic or script.So, this is how the process looks like:
After installation, start the vREST NG Application and use vREST NG Pro version when prompted in order to proceed further.
Now first setup a project by dragging any empty directory from your file system in the vREST NG workspace area. vREST NG will treat it as a project and store all the tests in that directory. For more information on setting up project, please read this .For quick start, if you don't want to follow the whole process and just want to see the end result. They may download and add this in vREST NG application directly.Swagger
as Import SourceGenerate Data Driven Tests
. If this option is ticked then vREST NG Importer will generate the data driven test cases for each API spec available in the swagger file.So, before every test case execution, the test case will read the data from the linked CSV file and converts it into JSON format and store it in a variable named as data. Now the test case will iterate over the data received and run the iterations. So, if you make a change in CSV file, just run the test case again. Test Case will always pick up the latest state of the CSV file. No need to import again and again.
4. It has automatically inserted some variables in the API request params as per the API definitions available in the swagger file. These variables value will picked up from the linked CSV file automatically.5. It has automatically added the response validation logic as well. In the following image, status code assertion is used to validate the status code of the API response. Text Body with Default Validator assertion compares the expected response body with the actual response body of the executed API test case. Text body with Default Schema Validator assertion validates the API response structure through the JSON schema.
The expected status code will be picked up from the linked CSV file.
6. It has imported all the swagger schema definitions in the
Schemas
section available in the Configuration tab
.You may refer these schema definitions in the Expected Schema tab as discussed earlier. And in the CSV file, you will need to just specify the respective schema name for the test iterations in the expectedSchema column.
In this section, you can configure your various environments like prod, dev, staging etc. and their configurations using variables.
Now, let's execute this test in vREST NG Application. Both the iterations are failed because expected response body doesn't match with the actual response body as shown in the following image:Now, click on button "
Copy Actual to Expected
" for each iteration. vREST NG will directly copy the actual response body to expectedBody column in the linked CSV file.Now after this operation, if you look at the CSV file again. You can see that vREST NG has filled the expectedBody column for you as shown in the following image.Note: If you have opened this CSV file in Microsoft Excel then you will need to close the file and open it again in order to reflect the changes. But some code editors e.g. VS Code automatically detect the changes on the file system and reflect it in real time.
Now, if you execute the test again, you can see that the test iterations are now passing.You may also see the
expected vs actual response
for the selected test iteration:So, in this way, you may execute test iterations for an API via CSV file. Just add iterations in your CSV file and run it in the vREST NG Application directly. No need to import again and again. It all just work seamlessly. So, it increases your test efficiency and productivity drastically.
Note: You will also need to specify the
cpCmd
variable in the Environments
section because in Linux/MacOS the command name is cp
and for Windows OS, the command name is copy
. So, for Windows OS, you may create another environment in vREST NG application. So that your API tests can run on any machine by just switching the environment.I would like everybody to have your feedback on this approach whether you find it useful or not for your API testing needs. Do like if you find this post helpful. Feel free to in case if you need any help or if you want to use the vREST NG Pro version for free. Your feedback is essential for me to improve further.