1

UPDATE: SO I am getting the error whenever I have all meta tags like HostType,AspNetDevelopmentServerHost,URLToTest. So when I comment these tags I can run the test but I need to have these tags to have the connection string available for controller to connect to database. I created a basic unit test by just right clicking on the action in asp.net mvc and saying Create unit tests...I am just trying to run a basic unit test.I am getting this error -

The test adapter 'WebHostAdapter' threw an exception while running test 'IndexTest'. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting 'http://localhost:55767/VSEnterpriseHelper.axd' returned an error: The remote server returned an error: (500) Internal Server Error.

This is my method -

[TestMethod()] [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\\Users\\Administrator\\Desktop\\MyWebsite\\Websites\\Customer1\\Customer1", "/")] [UrlToTest("http://localhost:55767/Admin/Dashboard")] public void IndexTest() { DashboardController target = new DashboardController(); // TODO: Initialize to an appropriate value string id = string.Empty; // TODO: Initialize to an appropriate value ActionResult expected = null; // TODO: Initialize to an appropriate value ActionResult actual; actual = target.Index(id); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); } 

Any ideas what would be the problem here ? I tried to google but didnt get a good solution for my problem. I am using VS2010 Ultimate and asp.net mvc 2.0.

1
  • If possible, can you post the Index action method and the controller contructor (if any)? Commented Oct 19, 2010 at 17:05

1 Answer 1

1

I created a basic unit test by just right clicking on the action in asp.net mvc and saying Create unit tests..

When you do this on an ASP.NET web application project (which is what MVC uses) Visual Studio will generate a ton of crap and will try to start the web server every time you want to run a single unit test. You don't want this.

Here are two possibilities:

  1. When you start a new ASP.NET MVC project select that you want a unit test project in the default template (preferred).
  2. You already have an ASP.NET MVC project and you want to add unit tests to it. In this case simply right click on the solution and add a new project of type Test Project. Now add reference to the ASP.NET MVC project you are testing and add a new unit test (Add New Item).
Sign up to request clarification or add additional context in comments.

1 Comment

@Darin Dimitrov I thinks that this answer misses an important point in the question: "... I need to have these tags to have the connection string available for controller to connect to database..." In order to get a connection string from web.config you need to have a running web server.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.