CSC 309 Lecture Notes Week 8
Code Coverage
Acceptance Testing
public static int f(int i, int j) { int k; if (i > j) { i++; j++; } k = g(i,j); if ((k > 0) && (i < 100)) { i++; j++; } else { i++; } return i+j+k; } static int g(int i, int j) { return i-j+1; }
k > 0 | i < 100 | (k > 0) && (i < 100) | i | j | Remarks |
0 | 0 | 0 | 1 | 2 | i < j means k <= 0 |
0 | 1 | 0 | 100 | 101 | i < j means k <= 0 |
1 | 0 | 0 | 100 | 100 | i >= j mean k > 0 |
1 | 1 | 1 | 2 | 1 | i >= j mean k > 0 |
toreturn i+j+k;
return i+j-k;
toassertEquals(-2, ce.f(-2,-1));
assertEquals(-2, ce.f(2,-1));
toassertEquals(-2, ce.f(2,-1));
assertEquals(-2, ce.f(-2,1));
"Test coverage and post-verification defects: A multiple case study"
by Audris Mockus, Nachiappan Nagappan, Trung T. Dinh-Trong,
Proceedings of the 2009 3rd International Symposium on Empirical Software Engineering and Measurement,
October 2009