C# 指定的URL()与有效目录不对应。
尝试运行单元测试时,我遇到以下错误: 测试名称:GetMethodTest测试 全名:Quanser.Codex.App.Web.Repository.UnitTests.DocumentsControllerTests.GetMethodTest 测试来源:c:\Dev\Engineering\Mobile Apps\Software\Codex\trunk\Web\Repository\UnitTests.Repository\DocumentsControllerTests.cs :第34行测试结果:失败测试持续时间:0:00:00 结果消息:指定的URL(“”)不存在 对应于有效的目录。配置为在中的ASP.NET中运行的测试 IIS要求URL存在有效的目录。URL可能是 无效或可能未指向有效的Web应用程序 这是我的测试用例:C# 指定的URL()与有效目录不对应。,c#,asp.net,unit-testing,asp.net-web-api,C#,Asp.net,Unit Testing,Asp.net Web Api,尝试运行单元测试时,我遇到以下错误: 测试名称:GetMethodTest测试 全名:Quanser.Codex.App.Web.Repository.UnitTests.DocumentsControllerTests.GetMethodTest 测试来源:c:\Dev\Engineering\Mobile Apps\Software\Codex\trunk\Web\Repository\UnitTests.Repository\DocumentsControllerTests.cs :第34
[TestMethod()]
[HostType("ASP.NET")]
[UrlToTest("http://localhost:53364/")]
public void GetMethodTest()
{
// ...
}
我知道这句话有点不对劲:
[UrlToTest("http://localhost:53364/")]
我应该在这个属性中放置什么作为Url
注意:我需要使用这些属性来测试RESTAPI
感谢这些属性用于测试ASP.NET Web表单项目。如果您只需要测试您的WebAPI控制器,那么您应该能够删除它们,例如
[TestMethod()]
public void GetMethodTest()
{
// ...
}
也许这是[这篇文章][1]中描述的许可问题。[1]: