我为一个非常简单的代码添加了两个整数
public class SimpleCalculator
{
public int Add(int a,int b)
{
return a + b;
}
public int Multiply(int a, int b)
{
return a * b;
}
}
基于NUnit的小型UnitTest
[TestFixture]
[Category("Math")]
public class SimpleCalculatorTests
{
[TestCase(-5,10,5)]
[TestCase(0, 0, 0)]
[TestCase(2, 3, 5)]
[TestCase(7, 10, 17)]
[TestCase(30, 40, 70)]
[Category("Addition")]
public void ShouldAddTwoNumbers(int firstNum, int secondNum, int expectedNum)
{
//System Under Test - sut
var sut = new SimpleCalculator();
var result = sut.Add(firstNum, secondNum);
Assert.That(result, Is.EqualTo(expectedNum));
}
}
结果如下
为什么与其他测试相比,负数测试的持续时间如此之长?