The problems are based on the given Java programs contained in Triangle.zip. Do not make any changes to the code. If you choose to use a different object-oriented language, it is your responsibility to translate the code correctly.
Download Triangle.zip and unzip it. The source code has seven Java packages: correct, bug1. bug2,…, and bug6. Each package contains a class Triangle.java. Triangle.java in the “correct†package is a correct program that reports the type (RIGHT, OBTUSE, ACUTE and NOTRIANGLE) of a triangle whose three angles are given as integers (angleA, angleB, angleC). Triangle.java in each bugX (X=1, …, 6) package has a bug.
- Compare each buggy version of Triangle.java with the correct version of Triangle.java and describe the fault detection condition (including reachability, necessity, and propagation constraints) that any test case must satisfy in order to find the bug (refer to the slides on fault detection condition). Use the following table to document your answers (20 points).
- Complete the following table of equivalence classes. (20 points)
- Complete the following table of boundary values. (20 points)
- Complete the following table of test cases only based on the equivalence partitioning in (2) and boundary value analysis in (3). You should add new rows as needed. (10 points)
- Write a JUnit class TriangleTest.java in the “correct†package to implement all the test cases in (4). Here is a sample JUnit test.
- Based on the test cases in (4) and their execution in (5), complete the following table about the coverage of each conditional statement in the correct Triangle.java program (10 points).
- Copy your TriangleTest.java in (5) to each bugX (X=1, 2, …, 6) package. Make sure the package statement in TriangleTest.java is corrected so that you can test Triangle.java in the same package. Report your test results in the table below and attach a screenshot of the test execution for each bugX package. (10 points)
|
# |
Incorrect expression |
Correct expression |
Description of fault detection condition |
|
Bug1 |
if (angleA <= 1 || angleB <= 0 || angleC <=0){ |
if (angleA <= 0 || angleB <= 0 || angleC <=0){ |
|
|
Bug2 |
if (angleA+angleB+angleC > 180) { |
if (angleA+angleB+angleC != 180) { |
|
|
Bug3 |
if (angleA== 90 || angleB == 90) |
if (angleA== 90 || angleB == 90 || angleC == 90) { |
|
|
Bug4 |
if (angleA== 90 || angleB == 90 || angleC >= 90) |
if (angleA== 90 || angleB == 90 || angleC == 90) { |
|
|
Bug5 |
if (angleA > 90 || angleB > 90 || angleC > 91) |
if (angleA > 90 || angleB > 90 || angleC > 90) |
|
|
Bug6 |
if (angleA > 90 || angleB > 90 || angleC > 100) |
if (angleA > 90 || angleB > 90 || angleC > 90) |
|
Condition |
Valid classes |
Invalid classes |
|
angleA |
||
|
angleB |
||
|
angleC |
||
|
angleA+angleB+angleC=180 |
|
Variable |
Boundary values from valid classes |
Boundary values from invalid classes |
|
angleA |
||
|
angleB |
||
|
angleC |
||
|
angleA+angleB+angleC |
|
Test # |
Test Input |
Oracle Value (expected result) |
||
|
angleA |
angleB |
angleC |
||
|
1 |
||||
|
2 |
||||
|
3 |
||||
|
… |
||||
public void testAcuteTriangle () {
Triangle triangle =new Triangle(50, 60, 70);
assertTrue(triangle.reportTriangleType()==Triangle.TriangleType.ACUTE);
}
Run and debug TriangleTest.java in the “correct†package until there is no failure. If there is a failure, then something is wrong with your tests and you must fix it. Copy and paste your test code here, and attach a screenshot of your test execution that shows that all tests have passed. (10 points)
|
Conditional statement |
Is statement coverage achieved? |
Is branch coverage achieved? |
||
|
Yes/No |
If yes, list the test cases that achieved the statement coverage |
Yes/No |
If yes, list the test cases that achieved the branch coverage |
|
|
if (angleA <= 0 || angleB <= 0 || angleC <=0) |
||||
|
if (angleA+angleB+angleC!= 180) |
||||
|
if(angleA== 90 || angleB == 90 || angleC == 90) |
||||
|
if(angleA > 90 || angleB > 90 || angleC > 90) |
||||
Note: To get full credits for (2), (3), and (4), your tests must be able to find at least 4 of the bugs. These tests must result from the techniques in (2) and (3).
|
Version |
Test failure: Yes or No? |
If Yes, list the tests that failed; If No, explain why |
|
Bug1 |
||
|
Bug2 |
||
|
Bug3 |
||
|
Bug4 |
||
|
Bug5 |
||
|
Bug6 |








Jermaine Byrant
Nicole Johnson



