In this article, we will see how we perform setup and tear down operation for test cases in vREST.
Here is a video tutorial for the same:
<iframe width="560" height="315" src="https://www.youtube.com/embed/l21OoQu9ZA8?list=PLmua155_WrDyoe7dYDB3lCfh-UK4XicT6?ecver=1" frameborder="0" allowfullscreen></iframe>
The setup or tear down method is simply yet another test case in vREST. The idea is, you need to implement some kind of logic over REST API to initialize your test application. This can be done in two ways:
- Implement a REST API endpoint in the test application itself, which is open only in test environment and which will insert the initialization data upon invocation of the API.
Note: You may also create a separate application which loads data in your database and provides you an API for that.
- Create another application, which provide REST APIs to execute commands on the test machine in which test application's data resides. Now with the help of this application, we can insert database dumps through commands and these commands can be invoked via REST APIs.
We have created an external module named as vutil for this purpose. For installation, please visit Setup and Install vutil.