I am trying to help out a team to verify some of their stuff works with the new ASP.Net Web API 4 Beta. While they seem to have a number of unit tests of good quality, there was a dearth of integration tests. I set out to resolve that as simply as possible.
To clarify we are living here:
For full UI/user tests I’d deploy the whole app, but I still want my Functional Integration tests to be faster and run locally with ease if I can. For Web API, I was hoping for self hosting. WCF can do this, but WCF is a giant pile of mud that I’m not interested in attacking. So I went looking for Web API Self Hosting for Dummies. Found it.
Note: I’ve set the folder = “” in this sample since my ApiController is side-by-side with my test fixture. Assuming your ApiController is in a different assembly than your tests, you can sepcify the namespace: parameter in the MapHttpRoute like this:
namespaces: new[] { typeof(ThingsController).Namespace }
Pingback: Automated Testing of ASP.NET Web API and MVC applications | Robert Daniel Moore's Blog