logo

Crowdly

Have a careful look at the following Java program snippet and its associated tes...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Have a careful look at the following Java program snippet and its associated test case:

01 public class Computer {

02

03    public int compute (int integer) {

04       if (integer >= 2) {

05          return integer + 2;

06       }

07       return integer + 1;

08    }

09

10 }

11 class ComputerTest {

12

13    @Test

14    void testSmallInput () {

15       Computer comp = new Computer();

16       assertTrue(comp.compute(1) == 2);

17    }

18

19 }

 

To Do:

a) [1 mark] Apply the following mutation in line 04: ‘2’ is changed to ‘1’. Will the mutant be killed by the given test case?  Justify your answer.

b) [1 mark] Now apply the following mutation in line 04: ‘2’ is changed to ‘3’. Will the mutant be killed by the given test case?  Justify your answer.

c) [2 marks] Provide a test suite (i.e., test code) that would kill both of the mutants created in a) and b). If the test already provided in lines 11-19 needs to be changed, please state exactly how that change must look like (or provide the new test code). If test cases are missing, please add them. In any case, make it crystal clear how exactly the complete test code should look like and explain how the proposed test suite kills both mutants.

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.ut.ee?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!