Automating scenario executions with CircleCI
As a team developing a Web API, you would like to run your API tests each time the Web API project is built and deployed successfully.
To do so with CircleCI, you have two builds: one responsible for building and deploying the actual Web API, the other one responsible for the testing the deployed API. You can configure the first build so that it triggers the second one after each successful deployment.
The following figure provides an overview of this approach.
To trigger the execution of test scenarios after the Web API is successfully deployed, you need to leverage the deployment part of the CircleCI configuration and add a second command after the actual deployment. The second command is a call to the CircleCI API which will trigger the API test execution.
Here is an example of such configuration (with a deployment on Heroku).
deployment:
trigger:
branch: master
commands:
- git push git@heroku.com:myapp.git $CIRCLE_SHA1:master
- curl -v -X POST https://circleci.com/api/v1/project/templth/restlet-client-circleci/tree/master?circle-token=$CIRCLE_TOKEN
This way, each time you push a change, the API is built, deployed and tested.