ASP.NET MVC Application Testing Integration

I need advice on an efficient way to write integration tests for our current ASP.NET MVC application. Our architecture consists of:

  • Service Level Below Controllers
  • The service layer uses repositories and a message queue (sometimes) to send messages to external applications.

I think the following should be done:

  • Record behavioral unit tests for all parts separately. So, for example, we need a unit test service level, while ridiculing repositories and message queues.

  • The same goes for controllers. Therefore, we scoff at the level of service and unit test with the controller.

  • Finally, we write separate integration tests for repositories against a real database and message queue classes against real message queues to ensure that they save / retrieve data successfully.

My questions:

  • Are there any other types of integration tests we need to write?

  • Do I still need to write integration tests for Services with real repositories and message queues?

  • We still need to write integration tests for controllers with real services (which, in turn, consist of real repositories and message queues).

Any advice would be greatly appreciated.

Greetings

+6
source share
3 answers

Here at the office, we do not test real services.

  • We have a service side test.
  • We test controllers as unit tests, we use the layout in these unit tests
  • However, we do not have an integration test :-(

We were advised not to use real services for testing, we use Rhino Mocks to simulate responses to methods called inside controller actions.

So the problem is how to do integration tests well.

Perhaps this may help you:

http://www.codeproject.com/Articles/98373/Integration-testing-an-ASP-NET-MVC-application-wit.aspx

but I'm still looking for a better understanding of its capabilities.

+1
source

I use Ivonna to test different levels of isolation. I can verify that a specific Url with some POST data falls into the expected action method with the expected arguments, and at the same time I can mute / mock external services.

+1
source

I use SpecsFor.MVC to test integration. Essentially, you write code in a test class, and the environment launches a browser that interprets your C # in browser actions. It is beautifully easy to use and configure.

0
source

Source: https://habr.com/ru/post/885785/


All Articles