Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

progamming language is java you can ignore the branches just indicate what file the code goes in . only code is code you write to

progamming language is java you can ignore the branches just indicate what file the code goes in. only code is code you write to complete task. no preexisting code Task 1: Add to the class a method called buggyMethodl that contains a division by zero fault such that (1) it is possible to create a test suite that achieves 100% statement coverage and does not reveal the fault, and (2) it is possible to create a test suite that achieves less than 50% statement coverage and reveals the fault. o The method can have any signature. If you think it is not possible to create such a method, then create an empty method; add a comment in the (empty) body of the method that concisely but convincingly explains why creating such method is not possible. o Conversely, if you were able to create the method, create two JUnit test classes edu.qc.seclass.BuggyClass Testscla and edu.qc.seclass.BuggyClass TestsClb for class BuggyClass as follows: BuggyClass Testscla should achieve 100% statement coverage of buggyMethodl and not reveal the fault therein. o BuggyClass Test sclb should achieve less than 50% statement coverage of buggyMethods and reveal the fault therein. o Both classes should be saved in directory /test.(Also in this case, the actual path will obviously reflect the package structure, and the same holds for the test classes in the subsequent tasks.)Task 2: Add to the class a method called buggyMethod2 that contains a division by zero fault such that (1) it is possible to create a test suite that achieves 100% statement coverage and does not reveal the fault, and (2) every test suite that achieves more than 50% branch coverage reveals the fault. The method can have any signature. o If you think it is not possible to create such a method, then create an empty method; add a comment in the (empty) body of the method that concisely but convincingly explains why creating such method is not possible. o Conversely, if you were able to create the method, create two JUnit test classes edu.qc.seclass.BuggyClass Test SC2 and edu.qc.seclass.BuggyClass TestBC2 for class BuggyClass as follows: o BuggyClass TestSC2 should achieve 100% statement coverage of buggyMethod2 and not reveal the fault therein. o Buggyclass TestBC2 should achieve more than 50% branch coverage of buggyMethod2 and reveal the fault therein. o Both classes should be saved in directory /test.Task 3: Add to the class a method called buggyMethod3 that contains a division by zero fault such that (1) it is possible to create a test suite that achieves 100% branch coverage and does not reveal the fault, and (2) it is possible to create a test suite that achieves 100% statement coverage, does not achieve 100% branch coverage, and reveals the fault. o The method can have any signature. If you think it is not possible to create such a method, then create an empty method; add a comment in the (empty) body of the method that concisely but convincingly explains why creating such method is not possible. o Conversely, if you were able to create the method, create two JUnit test classes edu.qc.seclass.BuggyClassTestBC3 and edu.qc.seclass.BuggyClass Test SC3 for class BuggyClass as follows: o BuggyClassTestBC3 should achieve 100% branch coverage of buggyMethod and not reveal the fault therein. BuggyClassTest SC3 should achieve 100% statement coverage of buggyMethod3, less than 100% branch coverage of buggyMethod3, and reveal the fault therein. Both classes should be saved in directory /test.Task 4: Add to the class a method called buggyMethod4 that contains a division by zero fault such that (1) every test suite that achieves 100% statement coverage reveals the fault, and (2) it is possible to create a test suite that achieves 100% branch coverage and does not reveal the fault. o The method can have any signature. o If you think it is not possible to create such a method, then I create an empty method; add a comment in the (empty) body of the method that concisely but convincingly explains why creating such method is not possible. o Conversely, if you were able to create the method, create two JUnit test classes edu.qc.seclass.BuggyClass Test SC4 and edu.qc.seclass.BuggyClassTestBC4 for class BuggyClass as follows: BuggyClass Test SC4 should achieve 100% statement coverage of buggyMethod4 and reveal the fault therein. o BuggyClassTest BC4 should achieve 100% branch coverage of buggyMethod4 and not reveal the fault therein. o Both classes should be saved in directory /test. Task 5: Add to class BuggyClass a method buggyMethods by completing the code skeleton provided below so that (1) it is possible to create a test suite that achieves 100% statement coverage, and (2) the division by zero fault at line 4 cannot be revealed by any test suite. 1. public void buggyMethod5(int i){2. int x; 3.[point where you can add code]4. x = i/0; 5.(point where you can add code]6.} o In completing the method: you cannot add any extra parameter to the method; you cannot use any exception handling mechanism; you cannot use reflection. you cannot use any code rewriting technique. basically, you can only add zero or more lines of code to replace the placeholders "[point where you can add code]". If you think it is not possible to create such a method, then I create an empty method; add a comment in the (empty) body of the method that concisely but convincingly explains why creating such method is not possible. o Conversely, if you were able to create the method, create a JUnit test class edu.qc.seclass.BuggyClass TestsC5 for class Buggyclass as follows: o BuggyClassTest sc5 should achieve 100% statement coverage of buggyMethods and not reveal the fault therein. The class should be saved in directory /test. Create a directory called "Assignment7" in the root directory of the personal repo we assigned to you. Hereafter, we will call this directory . Create a Java class edu.qc.seclass.BuggyClass in directory /src.(The actual path will obviously reflect the complete package structure.)

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions