0

To everyone that took their time, to read my question, I want to point out, that I'm writing Integration-tests NOT Unit-tests.

Using the definition of Integration-test, provided by sites(that are at the bottom of the question):

Integration tests do not use mock objects to substitute implementations for service dependencies. Instead, integration tests rely on the application's services and components. The goal of integration tests is to exercise the functionality of the application in its normal run-time environment.

My question is what is the best practice on writing integration test for ASP.net web API. At the moment I'm using the in memory host approach provided by Filip. W. blog post.

My second question is, how do you ensure, that your test data is there and is correct, when you're not not Mocking(msdn and other sites clearly say, that integration test do not mock databases). The internet is filled with examples of how to write extremely simple integration tests, but has zero examples for more complex api(anything that goes further than returning 1)

Reference Sites: https://msdn.microsoft.com/en-us/library/ff647876.aspx
https://msdn.microsoft.com/en-us/library/vstudio/hh323698(v=vs.100).aspx http://www.codeproject.com/Articles/44276/Unit-Testing-and-Integration-Testing-in-Business-A http://blog.stevensanderson.com/2009/06/11/integration-testing-your-aspnet-mvc-application/

Filip. W. In-Memory-Hosting: http://www.strathweb.com/2012/06/asp-net-web-api-integration-testing-with-in-memory-hosting/

asked May 4, 2015 at 8:02

1 Answer 1

1

Have you seen my answer over at this other SO question here . I will pad this out with the additional information below.

In our release pipeline (using Visual Studio Release manager 2013) we provision a nightly integration database from a known test script by creating the database from scratch (all scripted) - initially we cloned production but as data grew this was too time consuming as part of the nightly integration build. After the db is provisioned we do the same with the integration VM web-servers and deploy the latest build to that environment. After these come up we run our unit tests again from command line as part of the release pipeline this time including the tests decorated with the custom action filter I descried in the answer linked.

answered May 4, 2015 at 10:07
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Your answer did give me a few toughs on how to do it, but I'll not mark it as an answer, since I would like to hear more opinions on this topic.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.