Question: computePrimes() has a fault that causes it not to include prime numbers whose last digit is 9. For example, it omits 19, 29, 59, 79,

 computePrimes() has a fault that causes it not to include prime

computePrimes() has a fault that causes it not to include prime numbers whose last digit is 9. For example, it omits 19, 29, 59, 79, 89, 109, ...

Answer the following questions a through f, if the test could be created describe what the test case would be or explain why it cannot be created:

  1. A test that does not reach the fault

b. A test that reaches the fault, but does not infect

c. A test that infects the state, but does not propagate

d. A test that propagates, but does not reveal

e. Write a Junit test that reveals the fault for the following input.

computePrimes(8);

Expected = [2, 3, 5, 7, 11, 13, 17, 19]

Result = [2, 3, 5, 7, 11, 13, 17, 23]

f. After repairing the fault, write a data-driven Junit test for the toString method with at least 3 different values. In particular, this data-driven test method should test toString method using @ParameterizedTest based on the results of computePrimes method for n = 7, 8 and 9.

public class PrimeNumbers implements Iterable { private List primes = new ArrayList(); public void computePrimes (int n) { int count = 1; // count of primes int number = 2; // number tested for primeness boolean isPrime; // is this number a prime while (count iterator() { return primes.iterator(); } @Override public String toString() { return primes.toString(); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!