Testing View without inject presenter?

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
May 2, 2008 at 8:18 PM
I've been using WCSF for a long time now, and just a little question disturb my mind now, How could I test the View without the need to inject the presenter in the view? right now the presenter is injected in their direct presentation (no interface or something) and as far as I know the view is instanced and then the presenter inside the view. This would make some trouble trying to mock the presenter in a "view only testing" environment.
Do anybody has the answer of have done this before?

Thanks a lot!
Coordinator
May 2, 2008 at 9:26 PM
Why do you need to test the view in unit tests?
When we created WCSF and CWAB (the Composite Web Application Block), we followed the Model-View-Presenter pattern, as it allowed us to unit test (actually TDD) the important parts of the code. If you look at the sample applications and quickstarts, the Views are dead simple. Most view methods are one to two lines of code, and can be inspected and tested via the UI in end-to-end functional tests, rather than unit tests.

Do you really need to unit test the View? Or can this be tested another way (say using WATIN like we did in the acceptance test project for the Order Management RI)?

Michael Puleio - patterns & practices
Bloghttp://blogs.msdn.com/mpuleio/
May 2, 2008 at 9:33 PM
I have generally only setup unit tests for my presenters, controllers and services. I too have wanted unit test my views. However, my testing of my views tends to be more manual integration by running my application. The ASP.NET Page Life Cycle can really interfere with true unit testing. I have seen applications like RSS Bandit use Cassini web server to host pages and test them automatically, however, I do not think this is what you or I want.

I hope you will share any solutions to this problem.


cristianp wrote:
I've been using WCSF for a long time now, and just a little question disturb my mind now, How could I test the View without the need to inject the presenter in the view? right now the presenter is injected in their direct presentation (no interface or something) and as far as I know the view is instanced and then the presenter inside the view. This would make some trouble trying to mock the presenter in a "view only testing" environment.
Do anybody has the answer of have done this before?

Thanks a lot!