Continuous Integration, Deployment and Testing of your Web APIs with AppVeyor and Runscope

Published on November 25, 2014

Fast iterations can be very valuable to the software development process, but make for more time spent doing deployments and testing.  Also, more deployments means more opportunities to accidentally introduce breaking changes into your API. 

RubeGoldbergMachine

AppVeyor is a cloud based continuous integration server and Runscope enables you to do integration testing of your Web APIs, when these services are combined they can save you time doing the mechanical stuff and ensure your API consumers stay happy.

The following steps show the key points to achieve this integration using AppVeyor, Runscope and Azure websites.

1) Create your Web API solution.

image

2) Commit your source code to a publicly accessible source code repository in Github, BitBucket, Visual Studio Online or Kiln.

3) Setup a default AppVeyor project.

image

3b) If  you did not include your Nuget packages in source control then you will need to go to the “Settings –> Build” page and add the nuget restore command.

image

4) Create an Azure Web Site from the Azure management portal using the Quick Create option.   After the site has been created you should setup deployment credentials.

image

5) Return back to the AppVeyor project configuration and setup the deployment of the project using Web Deploy.

image

The Web Deploy Server field should be set to

https://{sitename}.scm.azurewebsites.net/msdeploy.axd?site={sitename}.azurewebsites.net

Where {sitename} must be replaced by whatever you chose to name your Azure Website.  The Username and Password should be set to the credentials you provided in the Azure portal.

6)  Create your Runscope API tests.

image

7) Determine the trigger URL to initiate the tests.  An individual test can be triggered using the trigger URL on the test Settings page.

image

If you want to run all the tests defined in a bucket, there is also a trigger URL in the bucket settings page.

8) Configure AppVeyor to call Runscope Trigger URL.

image

Once this is all setup, as soon as you commit a change to the source code repo, AppVeyor will be notified of the commit and it will initiate a build.  Once the build is completed successfully, the Runscope trigger URL will be called and the newly deployed API will be tested.  Runscope notifications can be used to send emails, SMS messages or IMs if desired.

Image Credit: Lego Rube Goldberg machine https://flic.kr/p/8tA1H7