Issue #1: Can’t generate tests for a Web Application Project

  1. Create a Web Application Project (WAP)
  2. Add a class and methods to the project, and try to generate tests against them
  3. Get the following error message in the “Create Unit Tests” dialog: “Unable to load or locate assembly”, and can’t check or expand the WebApplication node:
    Issue#1

 

Workaround

1.      Add the Web Application Project Assembly via the “Add Assembly…” button (located on the bottom left of the dialog). 

a.      After adding the assembly, you may get an error message box saying: “One or more of assemblies you selected could not be loaded. Please check those assemblies are valid and try again:”; just hit OK; and afterwards, you will be able to select the methods that you want to generate tests against.

2.      After generating the tests, you must add the correct namespace (Microsoft.VisualStudio.TestTools.UnitTesting.Web) and the proper attributes to the test method for the test to execute properly. The required attributes include [HostType] (set to ASP.NET), [AspNetDevelopmentServerHost] (set to the path to the web site), and [UrlToTest] (set to the URL to test). For example:

/// <summary>

        ///A test for Class1ConstructorTest

        ///</summary>

        [TestMethod()]

        [HostType("ASP.NET")]

        [AspNetDevelopmentServerHost("%PathToWebRoot%\\WebSite2", "/WebSite2")]

        [UrlToTest("http://localhost/WebSite2")]

        public void Class1ConstructorTest()

        {

           

        }

 

3.      That’s it, you’re ready to go!

 

Issue #2: When running ASP.NET unit tests against an ASP.NET Development Server (A.K.A. Cassini), they fail with the following error message: “Could not find WebDev.Webserver.exe”

 

Workaround

  1. Make sure you don’t have VS2005 installed (if you do, you shouldn’t see the issue)
  2. Browse to the Orcas IDE directory and find WebDev.Webserver.exe
  3. Copy it to %windir%\Microsoft.NET\Framework\v2.0.50727

 

3. Issue #3: Can’t generate tests for an ASP.NET Web Site Project

  1. Create an ASP.NET Web Site
  2. Add an APP_Code folder to the web site, and then add a class to the folder.
  3. When attempting to generate tests against the class, see that the “Create Unit Tests” dialog is collapsed and nothing is checked. If you try to check anything, you might get the following error message: “Child nodes not allowed.”
  4. Even if you fix the problem in step #3 by modifying the web site's web.config file, the tests are generated, but building the web site will show compilation errors: “The type or namespace name ‘Class1’ could not be found (are you missing a using directive or an assembly reference?)”

Workaround

Unfortunately, we don’t have a workaround for this problem. The only thing that will work in this scenario is having a Visual Studio Team System 2005 web site project, and opening it in Orcas (going through the conversion wizard, which should be automatic when opening any old project in Orcas).

Hope this helps.

 

Thanks,
David Gorena Elizondo