Question: use mutation testing to test how good the test cases are in TriangleTest class. The code in Triangle class is used to classify rectangles into

use mutation testing to test how good the test cases are in TriangleTest class.

The code in Triangle class is used to classify rectangles into invalid, equilateral, isosceles and scalene.

The functions are implemented as follows:

isValid_1: returns true (not valid) If any of the triangle sides is negative, otherwise returns true.

isValid_2: return true (not valid) if the triangle sides do not satisfy the triangle invariant, otherwise returns true.

IsEquilateral: returns true if it is a valid triangle and all three sides have the same length,

otherwise returns false

. IsIsosceles: returns true if it is a valid triangle and has two sides of equal length, otherwise returns false.

IsScalene: returns true of it is a valid triangle and has all its sides of different lengths

.................................................................................................................

package com.classifying_triangles;

public class Triangle {

boolean isValid_1(int a, int b, int c) {

if (a <= 0 || b <= 0 || c <= 0) {

return false; // invalid

}

return true;

}

boolean isValid_2(int a, int b, int c) {

if (! (a + b > c && a + c > b && b + c > a)) {

return false; // invalid

}

return true;

}

boolean isEquilateral(int a, int b, int c){

if(isValid_1(a, b, c) && isValid_2(a, b, c))

if (a == b && b == c) {

return true; // equilateral

}

return false;

}

boolean isIsosceles(int a, int b, int c){

if(isValid_1(a, b, c) && isValid_2(a, b, c))

if (a == b || b == c || a == c) {

return true; // isosceles

}

return false;

}

boolean isScalene(int a, int b, int c) {

if(isValid_1(a, b, c) && isValid_2(a, b, c))

if (a != b && b != c && a != c) {

return true; // scalene

}

return false;

}

}

...............................................................................................................

package com.classifying_triangles;

import static org.junit.Assert.*;

import org.junit.Before; import org.junit.Test;

public class TriangleTest { Triangle t; @Before public void setup() { t = new Triangle(); } @Test public void testIsValid_1() { assertFalse(t.isValid_1(0, 0, 0)); } @Test public void testIsValid_2() { assertFalse(t.isValid_2(1, 1, 3)); } @Test public void testIsEquilateral() { assertTrue(t.isEquilateral(2, 2, 2)); } @Test public void testIsIsosceles() { assertTrue(t.isIsosceles(2, 2, 3)); } @Test public void testIsiScalene() { assertTrue(t.isScalene(2, 3, 4)); }

}

. Using Pitclipse 2.2.0 plugin in the eclipse ide, run mutation testing against the provided code.

2. Write a report which shows the following:

a. The total number of mutations generated and killed using the test cases provided in TriangleTest class.

b. For the remaining mutants, show where they exist and how you managed to kill each one of them (if possible).

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!