Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions