Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing the output of a RazorViewEngine View

Testing the UI has always been one of the difficulties in TDD, but I had gotten the impression that with the Razor ViewEngine in MVC3, it was possible to get the output that would be rendered for a particular view and set of inputs. You could then use string functions such as "Contains()" to verify the presence or absence of particular text that you expect to see in the output.

However, I can't seem to figure out how to do that, at least not without a LOT of mocking and scaffolding code. And I haven't been successful in finding anything on the top by Googling.

Can anyone point me to a link, or give me some pointers before I waste a couple days re-inventing the wheel by writing the scaffolding functions?

Thanks

like image 907
Dave Hanna Avatar asked Jan 31 '26 02:01

Dave Hanna


1 Answers

You may find the following blog post useful. Also testing rendered HTML by views is not exactly something I would call unit test. It's more of an integration test. There are tools which are specifically designed for performing UI tests.

like image 76
Darin Dimitrov Avatar answered Feb 03 '26 08:02

Darin Dimitrov