I have an ASP.NET website (.NET 4). I am trying to add Unit Testing (using Unit Testing Framework of VS 2010 ultimate) to code are located in the App_Code folder.
I have the following method in my unit test project:
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\..\\MyProject", "/MyProject")]
[UrlToTest("http://localhost:45156/MyProject/Inicio.aspx")]
public void TestMethod1()
{
Page page = TestContext.RequestedPage;
Assert.IsTrue(false, "Test ran, at least.");
}
I have the following web.config in my ASP.NET website:
<?xml version="1.0"?>
<configuration>
<system.web>
<xhtmlConformance mode="Strict"/>
<authorization>
<deny users="?"/>
</authorization>
<!--another tags like pages, httpRuntime, compilation, sessionState, trace and globalization-->
</system.web>
</configuration>
I'm getting this exception:
"The test adapter 'WebHostAdpater' threw an exception while running test 'TestMethod1'. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://127.0.0.1:45156/MyProject/VSEnterpriseHelper.axd' (required) returned an error: The remote server returned an error: (500) Internal Server Error..."
The page works as it should in a browser at the url: http://localhost:45156/MyProject/Inicio.aspx
This is very similar to the problem found here: - 500 Error Running Visual Studio ASP.NET Unit Test - Visual Studio 2010 Professional - Problem Unit-Testing Web Services - ASP.NET Performance Profiling 404/500 errors - VS2010 and ASP.NET unit test problems / WebHostAdapter exception - Unit Testing ASP.net Web Site Project code stored in App_Code
However, I haven't been found the solution for my project using the solutions than the similar problem. I have spent a couple days having this error. I hope you can help me.