11

我们在 VS 2008 专业版中进行了单元测试,并且遇到了一个可能相当大的障碍:似乎无法确定这个特定 VS 版本中的代码覆盖率。似乎这仅在 VS Team System Development Edition 中可用。

换句话说,VS 2008 专业版允许您编写所有您想要的单元测试,但无法检查哪些代码没有关联的单元测试(或者测试覆盖了多少代码)。这个观察正确吗?

如果是这样,有人可以推荐一个第三方工具来确定代码覆盖率吗?我尝试了 TestMatrix,但完全不为所动(设置屏幕在 120 DPI 时隐藏了 OK 和 Cancel 按钮,运行我当前的一组测试导致完全 VS 锁定)。

一个附带问题:与其升级到 VS Team System Development Edition,不如使用 3rd 方覆盖工具,采用 NUnit 并找到免费/低成本的代码覆盖工具是否更有意义?我们还没有深入到单元测试中,我们希望选择一种不会妨碍我们努力的测试方法......并且不会破坏银行。

4

3 回答 3

3

无盖

于 2008-10-08T18:21:20.940 回答
1

我正在使用PartCover从我的 NUnit 测试中获取有关代码覆盖率的基本信息。虽然界面不是阳光下最流畅的体验,但它可以完成工作并且是开源的。

于 2008-10-08T18:19:57.857 回答
0

I've been using NCover with NUnit under VS2008 for a few days. I've found it so easy to find and fill gaps in my test coverage, I've giggled aloud when NCover pops up.

One tip: if your tests are in the same file as the code they're testing, don't bother running NCover unless all of your tests pass. Otherwise, it'll flag all the failing test methods' trailing braces as uncovered. Though, perhaps that's just a hint that I should be putting my tests in a different file…</p>

于 2008-10-14T10:21:42.953 回答