Posts

Showing posts with the label Java Unit Testing

Array List Reverse and Rotation Lab-11 George Mensom University with passed test cases

Fill in the definitions to two ArrayList utility methods in the ALUtils class which is outlined below and included in the code pack for this lab. The methods are described in more detail below.import java.util.ArrayList; public class ALUtils{ // Creates a copy of the parameter a. Reverses the order of elements // in the copy and returns the reversed copy. Assumes a is non-null. public static <T ArrayList<T reverse(ArrayList<T a){ // Your definition here } // Creates a copy of the given ArrayList a and rotates the copy to // the right by the given shift. Elements at high indicies wrap // around to lower indices. Assumes parameter a is non-null and // that shift is a non-negative number. Returns the rotated copy. public static <T ArrayList<T rotate(ArrayList<T a, int shift){ // Your definition here } }In ALUtils, write a method reverse(aL) that takes any type of ArrayList and creates a reversed copy of it which is returned. The nature of this method is ...

[SOLVED] Branch Coverage, Statement Coverage and Path Coverage | Java Unit Testing

Create a directory called “TestClassValue” Hereafter, we call this directory <dir>. Create a Java class com.work.sample.FlawedClass in directory <dir>/src. (The actual path will obviously reflect the package structure.) 100% Branch Coverage & 100% Statement Coverage Add to the class a method called flawedMethodl that contains a division by zero fault such that it is possible to create a test suite that achieves 100% branch coverage and does not reveal the fault every test suite that achieves 100% statement coverage reveals the fault. Conversely, if you were able to create the method, then create two JUnit test classes com.work.sample.FlawedClassTestBCl and com.work.sample.FlawedClassTestSCl for class FlawedClass as follows: FlawedClassTestBCl should achieve 100% branch coverage of flawedMethodl and not reveal the fault therein. FlawedClassTestSCl should achieve 100% statement coverage of flawedMethodl and reveal the fault therein. Both classes should be...

Branch Coverage, Statement Coverage and Path Coverage | Java Unit Testing

Create a directory called “TestClassValue” Hereafter, we call this directory <dir>. Create a Java class com.work.sample.FlawedClass in directory <dir>/src. (The actual path will obviously reflect the package structure.) 100% Branch Coverage & 100% Statement Coverage Add to the class a method called flawedMethodl that contains a division by zero fault such that it is possible to create a test suite that achieves 100% branch coverage and does not reveal the fault every test suite that achieves 100% statement coverage reveals the fault. Conversely, if you were able to create the method, then create two JUnit test classes com.work.sample.FlawedClassTestBCl and com.work.sample.FlawedClassTestSCl for class FlawedClass as follows: FlawedClassTestBCl should achieve 100% branch coverage of flawedMethodl and not reveal the fault therein. FlawedClassTestSCl should achieve 100% statement coverage of flawedMethodl and reveal the fault therein. Both classes should be...