5

I've spent half a day trying to get an ASP.NET unit test to work as described in Alan's Development Blog. I don't have VS2008 but VS2010 with SP1 and Resharper 5.1, and no matter what I try I just run into different kinds of errors.

When I add a test project with a test method as follows and specify .NET 4 as target framework, I run into exception

Updated to show more detailed information about the 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://localhost:49676/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error..."

[TestMethod]
[HostType( "ASP.NET" )]
[UrlToTest( "http://localhost:49676/Default.aspx" )]
[AspNetDevelopmentServerHost( @"C:\...\Projects\ProjectX\ProjectX\", "/Default.aspx") ]
public void TestMethod1()
{

}

I've performed numerous searches on the internet regarding this error message, but never really found a solution - I tried adding a section so all users would be allowed access to "VSEnterpriseHelper.axd" which is also mentioned in the error message, but it didn't help.

Trying to set the test project's target framework to .NET 3.5 also doesn't help and returns the same error.

While playing around with different settings I also happened to get the error message that the assembly "Microsoft.VisualStudio.QualityTools.CommandLine" couldn't be loaded, even though I added the correct version (with the correct public key token) as reference.

Maybe the combination of things (ReSharper, .NET target framework, ...) messes things up, but I also tried disabling the ReSharper unit testing so that MSTest would be used, unfortunately to no avail.

The description in Alan's blog post seems to be quite straightforward, but it doesn't want to work for me.

Update 2

I also tried to run the example projects from Alan's page in VS2008, but the error is still the same as in VS2010 SP1.

Update 3

Still no luck, but I've added the file Microsoft.VisualStudio.Enterprise.AspNetHelper.dll (located in %PROGRAMFILES%\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies) to the web.config as a ConfigurationErrorException in the Windows Event Log indicated that this file was not found:

<dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentityVersion name="Microsoft.VisualStudio.Enterprise.AspNetHelper" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <codeBase version="10.0.0.0" href="file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio%2010.0/Common7/IDE/PrivateAssemblies/Microsoft.VisualStudio.Enterprise.AspNetHelper.dll" />
</dependentAssembly>

This fixed the problem with the AspNetHelper.dll, but I get the same error message for the AspNetAdatpter, but amending the web.config in the same way doesn't work as the error persists. Within Visual Studio I can also see that (when I try to add a handler entry as shown below) the QualityTools.HostAdapters.ASPNETAdapter part is shown in red, indicating in a tooltip "Cannot resolve symbol 'QualityTools'":

<add name="HostAdapter" verb="GET" path="ASPNETAdapter" type="Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNETAdapter, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

This is all a big mess, and it seems I've completely lost track, why does it seem to be impossible to run ASP.NET unit tests within VS2010? Is there nobody else who's got the same kind of problems (or, ask the question differently, is there anybody who can run ASP.NET unit test in VS2010 without problems)?

Still trying to get things working...

Update 4

Still no luck, am I the only one? Who can run such tests?

End of update

Any ideas what I'm doing wrong here? Thanks in advance for any pointers into the right direction

G.

Gorgsenegger
  • 7,356
  • 4
  • 51
  • 89
  • Could you look at the event log and find the exact exception ? that might be helpful. – KeesDijk Apr 19 '11 at 09:03
  • I've updated the description to show the full text of the exception, as mentioned above I already tried to add a section to the web.config to allow access to all users to the VSEnterpriseHelper.axd. I've also read that the web.config is modified automatically while tests are run so that step shouldn't be necessary anyway. – Gorgsenegger Apr 19 '11 at 09:13
  • did you look at this http://stackoverflow.com/questions/260432/500-error-running-visual-studio-asp-net-unit-test – Aravind Apr 26 '11 at 09:03
  • Yes, but this doesn't solve the problem. I always end up with "Unable to find assembly 'Microsoft.VisualStudio.QualityTools.HostAdapters.ASPNetAgent, ...' – Gorgsenegger Apr 26 '11 at 09:37

4 Answers4

0

I'm a year too late but i just had this error and had a quick google. All results said to disable code coverage but that option wasnt available for me. All i done was check the localhost ports and i had the wrong one and it all worked fine.

for those that don't know, run the project UI and check the process in the task bar. you can hover and check it or right-click and show details.

I changed this by double-clicking the testsettings and changing the host type to ASP.NET and then setting the "URL to test" to "http://localhost:49676/Default.aspx" the port number to change is in bold. however in the question at the top a tag is used "[UrlToTest( "http://localhost:49676/Default.aspx" )]". I think this does the same thing.

FYI, I've only been developing C# just over a year, sorry if I state the obvious.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
RooN3y
  • 144
  • 1
  • 7
0

I have a similar problem and the only solution I've found so far is changing the application pool to classic, instead of integrated.

Richard Anthony Hein
  • 10,550
  • 3
  • 42
  • 62
0

You can use Ivonna for Asp.Net testing. More features, and much cleaner test syntax imo.

ulu
  • 5,872
  • 4
  • 42
  • 51
  • This looks interesting, but there is quite a huge price tag on it. I'd still expect VS2010 to be usable for such tests, unfortunately there don't seem to be too many people with the same problems... – Gorgsenegger Sep 01 '11 at 09:30
0

I've run into the same issue, disabling code coverage analysis does fix this for me.

But unfortunately this is no option in my case.

Michael Sander
  • 2,677
  • 23
  • 29