MVC Benefits for Control Modules

My application already has a unit test for the domain. I would like to know what are the pros and cons of unit testing controller

and which test cases should be written when testing controllers.

thank

+5
source share
5 answers

It depends.

Validation, redirection, temporary messages, etc. may occur in controllers. You can argue that these operations should be tested in the same way as your models.

, Fat Model, Skinny Controller. , , . , (Selenium, Cucumber ..), . , . , . , , . , - , json .. , .

ASP.NET MVC2 . . , , , . /, - .

, , , . . , - , ;)

+5

, :

  • , (, , ..).
  • (, , , )
  • /
+1

A 'Pro' :

, .

, , , . , .

A 'Con' :

, - .

0

, - , , , .

, , linq . -, - . , .

: , . MVC. , .

0
source

One of the problems that I found in test controllers is that in some cases you need to emulate the execution chain that ASP.NET MVC follows to really test your controller.

For example, if you have code in the OnExecuting method, you need to find a way to run this method when performing the actual action in your controller during the unit test.

0
source

All Articles