ASP.NET单元测试的Windows7 / IIS7 [英] ASP.NET unit testing Windows7/IIS7

查看:150
本文介绍了ASP.NET单元测试的Windows7 / IIS7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天花了几个小时尝试写对一个ASP.NET项目的一些单元测试。这是Visual Studio 2010中。

Spent several hours today trying to write some unit tests against an ASP.NET project. It's Visual Studio 2010.

使用Windows 7企业版与IIS7。

Using Windows 7 Enterprise with IIS7.

步骤我把为:


  1. 增加了新的测试项目,该解决方案

  2. 打开一个类文件作为网站(Member.vb)的一部分

  3. 类文件中右键点击并生成单元测试

  4. 选择我要生成存根,选择添加到我的测试项目的方法,然后单击确定

  5. 打开了在测试项目中产生MemberTest.vb文件,单击生成的测试之一中,点击在CURENT上下文中运行测试

在下面就我的 Windows XP专业版与IIS6 机这些precise步骤,它工作正常。

When following these precise steps on my Windows XP Professional with IIS6 machine it works fine.

但是在IIS7在 Windows 7企业版的机器上我得到:

However on the Windows 7 Enterprise machine on IIS7 I get:

指定的URL(的http://本地主机/ MyProject的')不
  对应于一个有效的目录。测试配置在ASP.NET中运行
  IIS需要一个有效目录的URL存在。该URL可能
  无效或可能不会指向有效的Web应用程序。

The URL specified ('http://localhost/MyProject') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application.

所以,这是怎么回事,我可以确认我可以浏览到的http://本地主机/ MyProject的并显示完美。

So what's going on, I can confirm I can browse to http://localhost/MyProject and it displays perfectly.

我确信我错过了一些在Windows / IIS配置的,但我真的很茫然。

I feel sure I'm missing some sort of config in Windows/IIS but I'm really at a loss.

生成的测试方法:

<TestMethod(), _
 HostType("ASP.NET"), _
 UrlToTest("http://localhost/MyProject")> _
Public Sub MyMethodTest()
    Dim target As Member_Accessor = New Member_Accessor() ' TODO: Initialize to an appropriate value
    Dim CurrentVal As Short = 0 ' TODO: Initialize to an appropriate value
    Dim expected As Short = 0 ' TODO: Initialize to an appropriate value
    Dim actual As Short
    actual = target.MyMethod(CurrentVal)
    Assert.AreEqual(expected, actual)
    Assert.Inconclusive("Verify the correctness of this test method.")
End Sub

(在 ASP.NET论坛

推荐答案

这可能是一个权限问题。

This could be a permissions issue.

如果您使用的是默认的目录(C:\\ USERS \\\\文档\\ Visual Studio 2010的\\项目),应用程序池的身份没有权限在那里。你不得不创造一些像C项目:\\网,并确保应用程序池的身份有权限的文件夹

If you're using the default directory (C:\users\\Documents\Visual Studio 2010\Projects), the app identity pool does not have permissions there. You'd have to create a project in something like C:\webs and make sure app pool identity has permission to the folder.

请参阅里克·安德森的博客文章在<一个href=\"http://blogs.msdn.com/b/rickandy/archive/2011/04/22/test-you-asp-net-mvc-or-webforms-application-on-iis-7-in-30-seconds.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/rickandy/archive/2011/04/22/test-you-asp-net-mvc-or-webforms-application-on-iis-7-in-30-seconds.aspx看看是否有帮助。

Refer to Rick Anderson's blog post at http://blogs.msdn.com/b/rickandy/archive/2011/04/22/test-you-asp-net-mvc-or-webforms-application-on-iis-7-in-30-seconds.aspx and see if that helps.

这篇关于ASP.NET单元测试的Windows7 / IIS7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆