Test Views in ASP.NET MVC2 (ala RSpec)
Posted
by Dmitriy Nagirnyak
on Stack Overflow
See other posts from Stack Overflow
or by Dmitriy Nagirnyak
Published on 2010-05-06T12:28:17Z
Indexed on
2010/05/19
22:50 UTC
Read the original article
Hit count: 353
Hi,
I am really missing heavily the ability to test Views independently of controllers. The way RSpec does it.
What I want to do is to perform assertions on the rendered view (where no controller is involved!). In order to do so I should provide required Model, ViewData and maybe some details from HttpContextBase (when will we get rid of HttpContext!).
So far I have not found anything that allows doing it. Also it might heavily depend on the ViewEngine being used.
List of things that views might contain are:
- Partial views (may be nested deeply).
- Master pages (or similar in other view engines).
- Html helpers generating links and other elements.
- Generally almost anything in a range of common sense :) .
Also please note that I am not talking about client-side testing and thus Selenium is just not related to it at all. It is just plain .NET testing.
So are there any options to actually do the testing of views?
Thanks,
Dmitriy.
© Stack Overflow or respective owner