Exercise 8
info
This is an in-class exercise. An exercise page like this one will contain a brief description but is intended to be supplemented by discussion during our meeting time. Complete the exercise to the best of your ability in the time given. Feel free to talk with other students as you work, and do not be afraid to ask questions. Aim to complete as much as possible during our meeting and continue to work at home to finish, but you need not hand it in.
#
Learning ObjectivesObjectives
This exercise should help you practice with:
- mutation analysis
- mutation testing
#
Answer the following questions- Elaborate the difference between mutation analysis and mutation testing.
- How exactly do you use mutation analysis in mutation testing?
- What is the difference between weekly killing and strongly killing a mutant?
- What is an equivalent mutant?
#
Task 1: Manual mutation analysis/testingConsider the following method:
- Write 4 mutants using
UOI
(Unary Operator Insertion) andROR
(Relational Operator Replacement). - Next, write tests to kill the mutants you wrote in step 1.
#
Task 2: Tool-supported mutation analysis/testingConsider the following method:
- Write test cases to achieve BC.
- Do mutation analysis by running
PIT
on your test suite and report the calculated mutation score as reported byPIT
. - If the mutation score is anything less than 100%, add more test cases to your test suite to reach 100%. If it is not possible to do so, explain why.
tip
Create a gradle
project and copy the above code into a new Java class. The following lines must be present in your build.gradle
to be able to use PIT
in your project:
The above assumes your source file classes are under exercises
package and your JUnit test files are under tests
package. Finally in order to have PIT
generate reports for you, run ./gradlew pitest
on a terminal. If things go well, you can find the generated report under build/reports/pitest
in your project folder.