Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean to unit test an MVC view?

On a new ASP.NET MVC application we are following a TDD approach, using NUnit for unit testing and Unity for Dependancy Injection.

Our views are being made as "dumb" as possible by adjusting our models to supply data in the most appropriate fashion for our views.

Is there a merit in unit testing our views? If so - how?

like image 715
Richard Ev Avatar asked Dec 13 '22 03:12

Richard Ev


1 Answers

The advantage of the MVC pattern is that views are supposed to be very lightweight and contain no code that needs to be tested.

If a view does contain code that needs to be tested, it should be moved out into the controller or model and unit tested there.

like image 50
cdmckay Avatar answered Dec 21 '22 11:12

cdmckay