How to initialize the whole ASP.NET MVC machinerie in order to test controllers?
<p>I have a solution with an ASP.NET MVC 5 project and a unit test project.
I have some code in some controllers that relies on the <code>HttpContext</code>:</p>

<pre><code>ApplicationUser applicationUser = await getApplicationUser(HttpContext.User.Identity.Name);
</code></pre>

<p>When running the automated tests that exercises the previous code I get an exception since <code>HttpContext</code> is not initialized.</p>

<p>I need to test my ASP.NET MVC controllers <strong>without mocking</strong> the actual running context.</p>

<p>I assume that this requires to initialize the framework with a fair amount of state (populating the <code>HttpContext</code> for example) and maybe to run the tests in an IIS environement.</p>

<p>There is the <a href="https://msdn.microsoft.com/en-us/library/ms182526%28VS.80%29.aspx" rel="nofollow">ASP.NET unit test project</a>, but it is <a href="https://social.msdn.microsoft.com/Forums/en-US/b53b3020-002f-40f7-aa48-b838ee454559/unit-test-for-a-webservice-vsenterprisehelperaxd?forum=vstswebtest" rel="nofollow">only capable of testing classic ASP.NET pages</a> and not MVC controllers.</p>

<p>How to make sure that integration tests run in an actual ASP.NET MVC context?</p>