# 计算机代写｜COM3529: Assignment 2

## 这是一篇来自英国的计算机作业代写

1 Introduction

This assignment concerns mutation testing. You should submit your answers as a PDF document via the Assessment page of the COM3529 module on Blackboard. The deadline for this work to be handed in is Friday 31st March, 3pm.

2 Question 1

Consider the fragment of code below. All variables are integer inputs.

if (a==b) {

if (x>y) {

if (x>=z) {

if (x==z) x=x+1;

}}}

else

y=y+1;

if (q==r)

x=y;

else

y=x;

1. (10 marks) Design a set of mutants such that if all mutants are killed then the test suite must have achieved 100% statement coverage.
1. (10 marks) Design a set of mutants such that if all mutants are killed then the test suite must have achieved 100% branch coverage.
1. (20 marks) Are your sets of mutants minimal (ie no set with fewer mutants is suffiffifficient)? Justify your answer and, if not, produce minimal sets.
1. (20 marks) Defifine three equivalent mutants for the code.
2. (10 marks) Defifine three stubborn mutants (mutants that are not equivalent but are killed by relatively few inputs). Ideally make these the most stubborn (the most diffiffifficult non-equivalent mutants to kill) that you can think of.
1. (10 marks) Find test input data to kill these stubborn mutants.

3 Question 2

Consider the following fragment of code in which three integer variables act as input (x, y, and z) and output is a method that outputs its parameter. The fragment of code checks whether the values for x, y, and z are increasing (in this order), decreasing, or unordered.

if (x>y && y>z)

output(“increasing”);

else if (x<y && y<z)

output(“decreasing”);

else

output(“unordered”);

In the following, you will need to explore the notion of multiple-condition coverage. This is a strictly stronger coverage criterion than branch coverage that aims to test the contribution that the individual conditions make. To see how multiple condition coverage works, consider a predicate (decision) in which there are two atomic predicates (conditions). The following is an example.

if (x>0 && y>0) z=1;

Here there is a decision x>0 && y>0 and the decision contains two conditions: x>0 and y>0. For branch coverage, it would be suffiffifficient to have one test case in which x>0 && y>0 evaluates to true and one under which it evaluates to false. Under multiple-condition coverage we instead require that tests cover all four combinations of truth values for the two conditions. We therefore require:

• A test case where, when execution reaches the if statement, x>0 is true and y>0 is true.
• A test case where, when execution reaches the if statement, x>0 is true and y>0 is false.
• A test case where, when execution reaches the if statement, x>0 is false and y>0 is true.
• A test case where, when execution reaches the if statement, x>0 is false and y>0 is false.

There is only one part to this question:

1. (20 marks) Design a set of mutants such that if all mutants are killed then the test suite must have achieved 100% multiple-condition coverage. E-mail: itcsdx@outlook.com  微信:itcsdx 