Testing Versioned API’s in ASP.Net Web API
I recently wrote about a framework for Versioning ASP.Net Web API. Continuing on the theme of versioning API’s, I researched how to test the different versions of a Web API, both for unit tests and SpecFlow acceptance tests.
Overview
As a quick review, the SDammann.WebApi.Versioning package was used for versioning the API and provides methods for selecting the controller that is active for a particular version of the API. At the code level the controller is selected by the name space of the particular version of the controller, e.g. Appname.Controllers.Version1. As mentioned in the last post, care must be taken to avoid unnecessary duplication in the controllers. Likewise the same duplication concerns apply for testing and relevant techniques will be reviewed in this post.