I understand that this is a duplicate of about 20 different posts, but not one of them is specific to MVC4, and not one of them that I saw really answers all my questions. So far, my first foray into the TDD world has been, at the very least, disappointing. Most of what I tried to do seems incompatible with MVC 4 or next to impossible without using poorly documented third-party libraries, which I still don't quite understand.
What I want to do is write tests that will validate my actions with the controller, the model that they pass, and the "Show action" view sends the model. I want to check if a view exists, I want to check if the model is the right type for the view, I would like to somehow check if it will be processed properly. I also want to check my routes. And testing authentication filters?
I need a unit test method ASP.Net MVC that leaves very little chance.
Testing the output of the Action model is simple enough, but checking the views was almost impossible.
So here is my list of questions:
- Once I test the action and get the result of the action, how can I check if the view that it wants exists?
- How to check my routes?
- How can I check if my views are being processed correctly?
- What is the "best practice" for unit testing THOROUGH ASP.Net MVC 4?
- How to do unit test form authentication?
- How to make unit test Action Filters?
I would prefer to use Visual Studio's built-in test projects, but if I have to use NUnit, I have to. I just need to make sure that this is done correctly.
Thanks in advance for your answers.
EDIT: I also could not get NUnit to work with my MVC4 application due to incompatibility with the .NET version. One of the collections was compiled.
unit-testing tdd visual-studio visual-studio-2010 asp.net-mvc-4
Ben Lesh Feb 10 2018-12-12T00 : 00Z
source share