Issue #1: Can’t generate tests for a Web Application Project
- Create a Web Application Project (WAP)
- Add a class and methods to the project, and try to generate tests against them
- 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:
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:
///A test for Class1ConstructorTest
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”
- Make sure you don’t have VS2005 installed (if you do, you shouldn’t see the issue)
- Browse to the Orcas IDE directory and find WebDev.Webserver.exe
- Copy it to %windir%\Microsoft.NET\Framework\v2.0.50727
3. Issue #3: Can’t generate tests for an ASP.NET Web Site Project
- Create an ASP.NET Web Site
- Add an APP_Code folder to the web site, and then add a class to the folder.
- 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.”
- 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?)”
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.
David Gorena Elizondo