You may make a copy of a worksheet and complete this activity or type your answers in any text editor.
You may work alone or with at most two other students in this course.
Consider (again) an implementation of the old engineering joke: Good, Fast, Cheap.
public final class GoodFastCheap
{
// boolean variables good, fast, and cheap
// and other stuff omitted
public boolean isSatisfactory()
{
if ((good && fast) || (good && cheap) || (fast && cheap))
return true;
return false;
}
public boolean isSatisfactoryRefactored()
{
if (good && fast) return true;
if (good && cheap) return true;
if (fast && cheap) return true;
return false;
}
}
Consider two mutation operators, one that replaces boolean variables with the constant "true" and one that replaces boolean variables with the constant "false". (Reminder: we are considering first-order mutation testing; i.e., only one change per mutant)
isSatisfactory()?
isSatisfactoryRefactored()?
isSatisfactory()
and the refactored version of the isSatisfactory() methods
(from Activity: Logic coverage for source code (gfc)).
Compute the mutation score for each RACC-adequate test set.
From Activity: Logic coverage for source code (gfc)
You may use the RACC-tests you picked or use the following tests.
The original isSatisfactory()
RACC-adequate test = { 2, 3, 4, 6 } // let's call it RACC-test1
The refactored version of the isSatisfactory()
RACC-adequate test = { 2, 3, 4, 5, 6, 7 } // let's call it RACC-test2
Compute the mutation score for RACC-test1 on isSatisfactory()
Compute the mutation score for RACC-test2 on isSatisfactoryRefactored()
You might find the following table useful. You should add more columns as needed.
p = ((g && f) || (g && c) || (f && c))
| Row | g | f | c | Original | ||||||||||||
| 1 | T | T | T | |||||||||||||
| 2 | T | T | ||||||||||||||
| 3 | T | T | ||||||||||||||
| 4 | T | |||||||||||||||
| 5 | T | T | ||||||||||||||
| 6 | T | |||||||||||||||
| 7 | T | |||||||||||||||
| 8 |
p1 = (g && f) p2 = (g && c) p3 = (f && c)
| Row | g | f | c | Original | ||||||||||||||
| p1 | p2 | p3 | ||||||||||||||||
| 1 | T | T | T | |||||||||||||||
| 2 | T | T | ||||||||||||||||
| 3 | T | T | ||||||||||||||||
| 4 | T | |||||||||||||||||
| 5 | T | T | ||||||||||||||||
| 6 | T | |||||||||||||||||
| 7 | T | |||||||||||||||||
| 8 | ||||||||||||||||||
CC-BY-NC-SA 4.0 license.