VS2012断点不会击中 [英] VS2012 Breakpoints are not getting hit
问题描述
我有一个类,看起来像这样:
I have a class that looks like this:
public class MyService
{
private MyService(){}
public static string GetStuff()
{
var stuffDid = new MyService();
return stuffDid.DoStuff();
}
private string DoStuff()
{
//do stuff
}
//other private helpers
}
很显然,我留下了很多了,但那是一般的外壳。
Obviously I left a lot out, but thats the general shell.
现在,我有一个单元测试:
Now, I have a unit test:
[Test]
public void MyTest()
{
var results = MyService.GetStuff();
}
我把我的单元测试断点,我可以看到结果
有数据。但是,我从字面上设置遍布为MyService
断点并没有被击中,除非我把它们放在一个大括号。我不能理解,因为结果
有数据,我的收益
语句为MyService
应击中了吧?
I set breakpoints on my unit test, and I can see that results
has data. However, I set breakpoints literally all over MyService
and nothing gets hit unless I put them on a curly brace. Which I can't understand since results
has data, my return
statements in MyService
should be getting hit, right?
我缺少的东西吗?难道我完全忘记了事物的最基本的规则是什么?在为MyService
没有被击中怎么来的?如果我手动踏进去与 F11
,它只是啤酒花周围,甚而不去直通每一行像我期望的那样。此外,当我踏上直通手动我倾向于打某些代码后我应该本来打它。而且任何开关
语句似乎默认为无论第一个选项是,即使寿正在切换应明确进入不同的情况下,值
。
Am I missing something? Did I completely forgot the most basic rules of something? How come nothing in MyService
gets hit? And if I manually step into it with F11
, it just hops around and doesnt even go thru every line like I would expect. Also when I step thru manually I tend to hit certain code after I should have hit it originally. And any switch
statements seem to default to whatever the first option is, even tho the value being switched should CLEARLY enter a different case
.
我甚至试图使为MyService
构造公共$ C 。$ C>,并带走所有的
静态
方法,它仍然不工作
I've even tried making MyService
constructor public
and taking away all static
methods, and it still doesnt work.
编辑:
我的测试和核心的代码在同一个解决方案,但不同的项目(测试
分别和核心
)。其他测试没有问题击中核心
破发点,仅此于特定的测试(即测试只测试为MyService $ C 。$ C>
My Tests and 'Core' code are in the same solution, but different projects(Test
and Core
, respectively). Other tests don't have an issue hitting break points in Core
, only this on particular test(the only test that is testing MyService
.
编辑2:
我已经删除了我的PDB文件和清理解决方案仍然一无所获
I've deleted my PDB files and cleaned solution. Still nothing.
推荐答案
原来,这是涉及到代码覆盖亮。
It turns out this was related to Code Coverage being on.
关闭它固定的问题。
您可以了解如何通过下面的链接
You can find out how to disable code coverage by following below link
这篇关于VS2012断点不会击中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!