ASP.Net Unit Tests Failing
1. Create a Web Service App.File - New Web Site – ASP.Net Web Service.(IIS based web site selected)
2. Create a New Class in the App_Code Folder of the new Web Site.
3. Add a simple HelloWorld Method to the new Class (Class1.cs in the instance)
4. Right click on method and select create Tests (Create new Test Project in same langague etc.)
The follwing test method is created as expected :-
[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("http://localhost/WebSite")]
[WebServerType(WebServerType.Iis)]
public void HelloWorldTest()
{
object target = TestProject1.Class1Accessor.CreatePrivate();
TestProject1.Class1Accessor accessor = new TestProject1.Class1Accessor(target);
string expected = null;
string actual;
actual = accessor.HelloWorld();
Assert.AreEqual(expected, actual, "Class1.HelloWorld did not return the expected value.");
Assert.Inconclusive("Verify the correctness of this test method.");
}
However when I run the test I get the following Error :
Could not connect to the web server for page 'http://localhost/WebSite'. The remote server returned an error: (403) Forbidden.. Check that the web server is running and visible on the network and that the page specified exists.
On investigating the IIS logfile it appears the test tries to hit 'http://localhost/WebSite' which is the application directory and as I have no default documents in the directory (e.g. default.htm, default.asp etc.) the Forbidden (i.e. directory browing turned off) will be the result.
Scenario 2 (File Based Web Site)
If I follow the same steps except I choose a File based web site I then get the following error when trying to execute the test :-
The web site for page 'http://localhost:1668/WebSites5' is not properly configured for testing. Check that Visual Studio Team Test tools are installed on the web server.

