2010-01-25 119 views
2

我在调试我的单元测试在ASP.Net MVC的问题。每当我尝试和调试选定的测试时,我设置的断点都会变成带有警告标志的空心圆。当我将鼠标悬停在它上面时,出现以下错误:Debuggin单元测试在ASP.Net MVC

“断点当前不会被触发,此文档没有符号加载。”

我在MSDN上搜索了这个错误,其中一个原因似乎是匹配的符号无法找到,所以断点无法从源映射到机器码。我不知道该怎么做。

  • 什么是这些标志是什么?
  • 如何创建呢?
  • 他们是否应该 自动生成?

作为一个方面说明,我可以调试我的常规项目就好了。这个错误似乎只影响我的项目的单元测试。谢谢您的帮助。

更新:

@jamesaharvey - 是的,到目前为止,我已经试过调试了几个我的测试结果相同,空心圆圈调试用的警告信号。

样品测试:

/// <summary> 
    ///A test for RequestForm with an existing user 
    ///</summary> 
    [TestMethod()] 
    [HostType("ASP.NET")] 
    [AspNetDevelopmentServerHost("C:\\projects\\webDirectoryCorrectionRequest\\trunk\\WebDirectoryCorrectionRequest\\WebDirectoryCorrectionRequest", "/")] 
    [UrlToTest("http://localhost:54191/")] 
    public void RequestFormTest_2() 
    { 
     //Create Controller 
     var controller = new FormController(); 

     //Create fake controller context 
     var formParams = new NameValueCollection { { "CN", "Swanson,Judith A" }, { "Type", "SNF" } }; 
     controller.ControllerContext = new FakeControllerContext(controller, formParams); 

     //FormController target = new FormController(); 
     var actual = controller.RequestForm() as ViewResult; 
     Assert.AreEqual("RequestForm", actual.ViewName); 
    } 
+0

这是您的所有考试吗?你能添加一个代码示例吗? – jamesaharvey 2010-01-25 18:11:51

+0

你如何运行你的单元测试? – Min 2010-01-25 18:14:22

+0

@Min - 我正在使用“测试视图”窗口单独运行每个测试或选择要运行的测试集合。对于我想调试的测试,我右键单击测试并点击调试选择。 – kingrichard2005 2010-01-25 18:18:27

回答

2

看看这有助于:http://forums.asp.net/p/1246417/2291629.aspx

[ClassInitialize()] 
public static void MyClassInitialize(TestContext testContext) 
{ 
    System.Diagnostics.Debugger.Launch(); 
} 

其实只是谷歌为http://www.google.com/search?q=AspNetDevelopmentServerHost+attach,似乎是一个很常见的问题。

+0

工作就像一个魅力,感谢queen3! :-)它也有助于阅读您发布的论坛链接,它确实揭示了整个过程。 – kingrichard2005 2010-01-26 17:16:02