The failing test, TestMultiply, decreases the coverage % plus the two methods, Subtract and Divide, do not have unit tests, which also decreases the coverage.
[TestFixture]
class TestCoverage_Class2
{
Coverage_Class1 initCoverage = new Coverage_Class1(55, 12);
[Test]
public void TestAdd()
{
Assert.AreEqual(67,initCoverage.Add());
}
[Test]
public void TestMultiply()
{
Assert.AreEqual(60, initCoverage.Multiply());
}
}
// Domain class being tested
public class Coverage_Class1
{
int firstValue, secondValue;
public Coverage_Class1(int a, int b)
{
firstValue = a;
secondValue = b;
}
public int Add()
{
return firstValue + secondValue;
}
public int Multiply()
{
return firstValue * secondValue;
}
public int Subtract()
{
return firstValue - secondValue;
}
public int Divide()
{
return firstValue / secondValue;
}
}
Make them all pass and voila, 100 % coverage !
Work around with the Threshhold values and you will increase your own coverage capabilities ! :) Happy Coverage! :)
No comments:
Post a Comment