title: How to unit-test a razor-view
body: <p>When Scott Guthrie <a href="http://weblogs.asp.net/scottgu/introducing-razor" rel="noreferrer">first blogged on Razor</a>, he wrote </p>
  
  <blockquote>
    <p>The new view engine implementation will support the ability to unit test views (without requiring a controller or web-server, and can be hosted in any unit test project – no special app-domain required).</p>
  </blockquote>
  
  <p>However, I can find no other statement (or example) regarding razor-testability.
  There are pointers to using the <a href="http://vibrantcode.com/blog/2010/7/22/using-the-razor-parser-outside-of-aspnet.html" rel="noreferrer"><code>CodelanguageServie</code></a> or <a href="http://blog.davidebbo.com/2011/06/unit-test-your-mvc-views-using-razor.html" rel="noreferrer">RazorGenerator</a> or <a href="http://buildstarted.com/2010/09/28/mvc-3-razor-view-engine-without-a-controller/" rel="noreferrer">some self-made renderer</a> - non of which I would call "by design".</p>
  
  <p>Is it currently possible to unit test a razor view the simple way? (In an asp.net mvc-application, that is. I.e. NancyFx brings testability in it's nancy.testing-package.)</p>
  
  <p>(And currently I don't care <a href="https://softwareengineering.stackexchange.com/questions/33909/why-is-testing-mvc-views-frowned-upon">if views should be tested or not</a>.)</p>
  
  <p>I know there are <a href="https://stackoverflow.com/questions/tagged/razor+unit-testing">loads of questions like this one</a>, but most of them are rather old...</p>