Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

What characteristic of a company does current ratio measure?

Answered: 1 week ago

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago