SoftwareTest HW3
1
2
Change
for(int i = 0; i<=numPrimes-1;i++)
into
for(int i = 0; i<numPrimes-1;i++)
3.N=1
[0,1,9,10,11,10,12]
4. node coverage
[0,1,2,3,4,5,6,7,8,1,9,10,11,10,12];
edge coverage
[0,1,2,3,4,5,4,5,6,7,8,1,9,10,12];
[0,1,2,3,4,7,1,9,10,11,10,12];
Prime path coverage
[0,1,2,3,4,5,4,5,4,5,6,7,8,1,2,3,4,7,1,2,3,4,7,8,1,9,10,11,10,11,10,12,];
[0,1,2,3,4,5,6,7,1,9,10,12]
Let’s test a right case and a wrong case, the result is following.
Code:(test case) package hw; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; public class HW3Test { HW3 pri = new HW3(); @Before public void setUp() throws Exception { } @After public void tearDown() throws Exception { } @Test public void test1() { int case1[] = {2,3}; assertArrayEquals(case1,pri.printPrimes(2)); } @Test public void test2() { int case1[] = {2,3,4,5,7}; assertArrayEquals(case1,pri.printPrimes(5)); } }