asp.net web层的单元测试

小小骨头 2011-12-14 05:30:53
微软上的范例:http://msdn.microsoft.com/zh-cn/library/ms243399

但是在我本地运行web层的单元测试,一直报

Could not connect to the Web server for page 'http://localhost:8549/'. 远程服务器返回错误: (500) 内部服务器错误。. Check that the Web server is running and visible on the network and that the page specified exists.

这样的错误。我该如何配置?
请各位赐教...
...全文
82 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
小小骨头 2011-12-15
  • 打赏
  • 举报
回复
/// <summary>
///
///</summary>
// TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
// http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
// whether you are testing a page, web service, or a WCF service.
[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("D:\\...\\..._CODE\\...\\PresentationLayer\\....Presentation.Web", "/")]
[UrlToTest("http://localhost:8549/")]
[DeploymentItem("Lrs.Presentation.Web.dll")]
public void InsertCodeExtensionInfoTest()
{
//Arrange
CodeList_Accessor target = new CodeList_Accessor(); // TODO: Initialize to an appropriate value

//Act
int expected = 1;
int actual = 1;
try
{
target.InsertCodeExtensionInfo();
}
catch
{
actual = 0;
}

//Assert
Assert.AreEqual(expected, actual);
}

你好,以上是我web层的一个测试代码。运行这个单元测试项,就会报我最先发的那个错...

我要测试web层中的所有方法,包括事件等...

可能我的方法不对,如您有好的建议,请不吝赐教...
阿非 2011-12-15
  • 打赏
  • 举报
回复
要测什么
小小骨头 2011-12-15
  • 打赏
  • 举报
回复
请问下,web层的测试该怎么做呢?
小小骨头 2011-12-15
  • 打赏
  • 举报
回复
呃...发现测试web层,就把那些url什么的删掉就行了...
阿非 2011-12-14
  • 打赏
  • 举报
回复
那个讲的web service 的单元测试
chenhaoying 2011-12-14
  • 打赏
  • 举报
回复
查看服务器的错误日志,看看详细的错误信息是什么,根据详细错误信息来解决问题。只有一个【(500) 内部服务器错误】谁都猜不出详细错误信息的。

62,266

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧