Question: write a method calledflawedMethod1 that contains a division by zero fault such that (1) it is possible to create a test suite that achieves 100%

  • write a method calledflawedMethod1 that contains adivision by zero fault such that (1) it is possible to create a test suite that achieves 100% branch coverage and doesnot reveal the fault, (2) any test suite that achieves 100% path coverage reveals the fault (and there must exist at least one such test suite).

The method can have any signature.

If such a method is possible, then it can be written with simple code.

  • If you think it is not possible to create a method meeting both requirements, then:
    • Create an empty method.
    • Add a comment in the (empty) body of the method thatconcisely but convincingly explains why creating such a method is not possible.
  • Conversely, if you were able to create the method, create two JUnit test classes as follows:
    • FlawedClassTestBC1 should achieve 100% branch coverage offlawedMethod1 andnot reveal the fault therein.
    • FlawedClassTestPC1 should achieve 100% path coverage offlawedMethod1 and reveal the fault therein.

Step by Step Solution

3.46 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Creating a method that satisfies both conditions seems to be impossible T... View full answer

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 Programming Questions!