ASP.Net Unit Tests Failing

Scenario 1 (IIS Based Web Site)

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.

[6467 byte] By [MarkDavies] at [2007-12-16]
# 1

Hi Mark,

Thanks for posting the issue on the Forum. I have a few options for you to try:

* Does the site use Redirection? Unfortunately, this isn't supported in Beta2.

* Did you specify an Application Pool other than 'ASP.NET V2.0'?

* Is 'default.aspx' in the list of default content pages?

thank you,

~ Michael

MichaelBrisset-MSFT at 2007-9-8 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...
# 2
Try turning off anonymous access to IIS - we had the same issue with the forbidden 403 error. Force it to use the Windows credentials that the Test tool will use to access the site.

Regards,

MichaelShorten at 2007-9-8 > top of Msdn Tech,Visual Studio Team System,Visual Studio Team System - Web and Load Testing...

Visual Studio Team System

Site Classified