在测试项目上进行测试覆盖,但在测试DLL时为零

时间:2014-07-03 17:34:27

标签: c# nunit teamcity-8.0

我已经构建了一个测试类,如下所示。

[TestFixture]
public class UnitTests
{
  [TestCase(3, 5, 8)]
  [TestCase(3, null, 3)]
  public void UnitTestMethod1(int? a, int? b, int expected)
  {
    int actual = Utilities.SomeSum(a, b);
    Assert.AreEqual(expected, actual);
  }

当我运行测试时,我的测试程序集上的值高于零,但在测试目标的程序集上为零。我可能做了什么愚蠢的事情?!我应该提供哪些更多信息?

测试类是超级基础的,如下所示。

使用System;

public class Utilities
{
  public static int SomeSum(int? a, int? b)
  {
    int? output;
    if (a == null && b == null)
      throw new Exception("Nulls!");

    a = a ?? 0;
    b = b ?? 0;
    output = a + b;
    return (int)output;
  }
}

当我在构建服务器上运行这些东西时,我在VS13中本地获得了不错的结果 - 奇怪的事情发生了。我得到了最新的nUnit / dotCover,并且在其他项目中都按预期工作。奇怪的...

1 个答案:

答案 0 :(得分:0)

请检查相应的PDB文件是否正确定位,并确保没有过滤器排除测试所针对的程序集。

相关问题