Software engineering – Test&Maint

I don’t understand this Computer Science question and need help to study.

Assignment #3

Turn in your work as a single Word or PDF file.

Problem 1

Problem 2

Problem 3

Total

1.1

1.2

1.3

2.1

2.2

2.3

2.4

3.1

3.2

30 pts

5 pts

5 pts

20 pts

20 pts

5 pts

5 pts

5 pts

5 pts

100 pts

This assignment is based on the given Java code in TriangleSidesAssignment.zip. The source code has 10 packages: correct, mutant1, mutant 2, …, and mutant 9. TriangleSides.java in the “correct” package is the original correct version. The reportTriangleType method in TriangleSides.java reports the type (EQUILATERAL, SCALENE, ISOSCELES and NOTRIANGLE) of a triangle, given the lengths of three integer sides a, b, and c. TriangleSides.java in each mutantX (X=1, …, 9) package is a mutant of the original version, where the reportTriangleType method is modified. The modifications are summarized below.

mutantX

Original

Mutated version

1

if (a<b+c && b<a+c && c<b+a){

if (b<a+c && c<b+a){

2

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

if (b==c)

3

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

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

4

return TriangleType. SCALENE;

return TriangleType.ISOSCELES;

5

if (a<b+c && b<a+c && c<b+a){}

else return TriangleType.NOTRIANGLE;

if-else removed

6

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

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

7

if (a<b+c && b<a+c && c<b+a){

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

8

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

if (a<=0 && b<=0 && c<=0)

9

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

return TriangleType.NOTRIANGLE;

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

// return TriangleType.NOTRIANGLE;

Note: Do not make any change to the code. If you choose to use a different programming language, it is your responsibility to translate all code correctly.

  • Mutation Testing
    • Compare each mutant with the correct version of TriangleSides.java and formulate the fault detection condition, including all reachability, necessity and propagation constraints. If the fault detection condition of a mutant is satisfiable, then create a test case that satisfies the condition, otherwise it is an equivalent mutant. Note that one test case may satisfy the fault detection conditions of multiple non-equivalent mutants. Try your best to find such cases although this is not required. This will help reduce the number of test cases.
    • Write a Junit class TriangleMutationTest.java in the correct package to implement all of your test cases in Problem 1.1. In the assertions, you many reference triangle types as follows:
    • Copy your TriangleMutationTest.java in Problem 1.2 to each mutantX (X=1, 2, …, 9) package. Make sure the package statement in TriangleMutationTest.java is correct so that you can test TriangleSides.java in the same package. This helps you verify your solution to Problem 1.1 – the test case of each mutant, if exists, should kill the corresponding mutant.
  • Specification-Based Testing
    • Define the test requirements based on the above specification. (20 points)
    • Create a set of test case specifications to meet all the test requirements in Problem 2.1. (20 points)
    • Write a Junit class TriangleSpecficationTest.java in the “correct” package to implement all the test cases in Problem 2.2. Run and debug TriangleSpecficationTest.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). Note that the tests in TriangleSpecficationTest.java must include only those from Problems 2.2.
    • Copy your TriangleSpecficationTest.java in Problem 2.3 to each mutantX (X=1, 2, …, 9) package. Make sure the package statement in TriangleSpecficationTest.java is correct so that you can test TriangleSides.java in the same package. Report your test results in the table below and provide a screenshot of the test execution result for each mutantX package. (5 points)
  • Evaluation of the Test Cases Created from the Decision Table
    • Write a Junit class TriangleDecisionTableTest.java in the “correct” package to implement all the test cases in the following table which results from the application of the decision table technique. Test cases 5, 6, and 8 in the decision table are not considered because they are infeasible. Run and debug TriangleDecisionTableTest.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).

Provide your fault detection conditions and test cases in the following table (30 points).

mutantX

Fault detection condition

Test case (input & oracle value) if it is a non-equivalent mutant

1

2

3

4

5

6

7

8

9

TriangleSides.TriangleType.EQUILATERAL

TriangleSides.TriangleType.SCALENE

TriangleSides.TriangleType.ISOSCELES

TriangleSides.TriangleType.NOTRIANGLE

Here is a sample Junit test:

@Test

public void testScalene() {

assertEquals(“”, new TriangleSides(5,12,13).reportTriangleType(),

TriangleSides.TriangleType.SCALENE);

}

Run your Junit tests and none of them should fail, otherwise your tests are incorrect and you need to fix them before moving on to the next problem.

Provide the source code of your TriangleMutationTest.java and the screenshot of the test execution result. (5 points)

Provide the screenshot of the test execution result for each mutantX (X=1, 2, …, 9). (5 points)

The specification of the TriangleSides program is as follows:

Preconditions

(1) Validated: (a>0 AND b>0 AND c>0)

On failure: return “NOTRIANGLE”

(2) Validated: (a+b>c AND a+c>b AND b+c>a)

On failure: return “NOTRIANGLE”

Postconditions

(3) IF (a=b AND b=c)

THEN return “EQUILATERAL”

(4) IF ((a=b AND b¹c) OR (a=c AND b¹c) OR (b=c AND b¹a))

THEN return “ISOSCELES”

(5) IF (a¹b AND b¹c AND a¹c)

THEN return “SCALENE”

a

b

c

a=b

b=c

a=c

a+b>c

b+c>a

a+c >b

Non-errorrequirements

Errorrequirements

Test Case ID

Test input

Expected result

Test requirements in (2.1) satisfied by the test

a

b

c

Non-error requirements

Error requirements

1

2

Provide the source code of your TriangleSpecficationTest.java and a screenshot of your test execution result. (5 points)

Note: To get full credits for Problems 2.1 and 2.2, your tests must be able to kill at least 5 mutants.

mutantX

Test failure: Yes or No?

If Yes, list the tests that failed; If No, explain why there is no failure according to the fault detection condition in Problem 1.1

1

2

3

4

5

6

7

8

9

Test Case ID

Test Input

Expected Result

a

b

c

1

4

1

2

Not a triangle

2

1

4

2

Not a triangle

3

1

2

4

Not a triangle

4

5

5

5

Equilateral

5

?

?

?

Impossible

6

?

?

?

Impossible

7

2

2

3

Isosceles

8

?

?

?

Impossible

9

2

3

2

Isosceles

10

3

2

2

Isosceles

11

3

4

5

Scalene

Provide the source code of your TriangleDecisionTableTest.java and a screenshot of your test execution result. (5 points)

mutantX

Test failure: Yes or No?

If Yes, list the tests that failed; If No, explain why there is no failure according to the fault detection condition in Problem 1.1

1

2

3

4

5

6

7

8

9

"Looking for a Similar Assignment? Order now and Get a Discount!