Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4. JUnit / Input partitionin g Black box testing [32 points] In the EEE dropbox

ID: 3604220 • Letter: 4

Question

4. JUnit / Input partitionin g Black box testing [32 points] In the EEE dropbox for Homework 2 (in "INF115-HW-10-31j/CourseFiles") is a Java Jar file called TriangleType.jar. Download this file to your computer. This jar file contains a class called TriangleType, which contains a public static method called triangleType(). This method takes three integers as input and outputs an integer. The three input variables each describe the lengths of each side of a triangle. The lengths of the sides of the triangle should be less than or equal to 1000. The output of this method will be one of 5 possible values: 1 for a scalene triangle, 2 for an isosceles triangle, 3 for an equilateral triangle, 4 for values that do not describe a triangle, and 5 for values that are out of bounds. Using Eclipse, create a new project. Under the Build Properties for the project, add the jar file as an external library. Create a new "JUnit Test Case." The new JUnit Test Case Class should be named TriangleTypeTest. The "Class Under Test" is TriangleType. Use JUnit4 (or JUnit5). You will be creating test cases for the method TriangleType.triangleType). 4a. [8 points] Describe, in English, how you would partition the input space for this program

Explanation / Answer

4a,

Firstly I would partition the input values in to Valid and Invalid inputs.

Valid Inputs: The ones with in the range (0,1000] are accepted and prompt the user for other values.

Invalid Inputs: The ones that fall out of the range. The values with in the valid range that cannot form a triangle i.e., if some of any two sides is less that the third side, then those values are invalid inputs.

4b,

4c,

import static org.junit.Assert.*;

import org.junit.Test;

public class TriangleTypeTest {

@Test

public void testValidinp1() {

int a = 0.5;

int b = 1;

int c = 1.2;

int r = TriangleType.triangleType(a,b,c);

assertEquals(r,1);

}

@Test

public void testValidinp2() {

int a = 995;

int b = 995;

int c = 1000.5;

int r = TriangleType.triangleType(a,b,c);

assertEquals(r,5);

}

@Test

public void testValidinp3() {

int a = 100;

int b = 500;

int c = 700;

int r = TriangleType.triangleType(a,b,c);

assertEquals(r,5);

}

@Test

public void testValidinp4() {

int a = 500;

int b = 600;

int c = 700;

int r = TriangleType.triangleType(a,b,c);

assertEquals(r,1);

}

@Test

public void testValidinp5() {

int a = -0.5;

int b = 1000.5;

int c = 8;

int r = TriangleType.triangleType(a,b,c);

assertEquals(r,5);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote