Skip to content

Commit

Permalink
fix tarantula formula
Browse files Browse the repository at this point in the history
  • Loading branch information
andre15silva committed Feb 21, 2024
1 parent 15ec83b commit aab4ddf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public double compute(double nPassingNotExecuting, double nFailingNotExecuting,
double passingTerm = nPassingNotExecuting + nPassingExecuting == 0 ? 0 : nPassingExecuting / (nPassingNotExecuting + nPassingExecuting);
double failingTerm = nFailingNotExecuting + nFailingExecuting == 0 ? 0 : nFailingExecuting / (nFailingNotExecuting + nFailingExecuting);

if (passingTerm == 0 || failingTerm == 0) {
if (passingTerm + failingTerm == 0) {
return 0;

Check warning on line 14 in src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/fr/spoonlabs/flacoco/localization/spectrum/formulas/TarantulaFormula.java#L14

Added line #L14 was not covered by tests
}

Expand Down
7 changes: 5 additions & 2 deletions src/test/java/fr/spoonlabs/flacoco/api/FlacocoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ public void testExampleFL1SpectrumBasedTarantulaDefaultMode() {
assertFalse(result.getExecutedTests().contains(new StringTestMethod("fr.spoonlabs.FLtest1.CalculatorTest", "testIgnore")));

Map<Location, Suspiciousness> susp = result.getDefaultSuspiciousnessMap();
assertEquals(5, susp.size());
assertEquals(6, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get(new Location("fr.spoonlabs.FLtest1.Calculator", 15)).getScore(), 0);

// Line executed by a mix of failing and passing
assertEquals(0.75, susp.get(new Location("fr.spoonlabs.FLtest1.Calculator", 14)).getScore(), 0.01);
Expand All @@ -140,7 +143,7 @@ public void testExampleFL1SpectrumBasedTarantulaDefaultMode() {
assertEquals(0.5, susp.get(new Location("fr.spoonlabs.FLtest1.Calculator", 6)).getScore(), 0);

List<Location> locations = result.getSuspiciousLocationList();
assertEquals(5, locations.size());
assertEquals(6, locations.size());
assertOrdered(susp, locations);
}

Expand Down

0 comments on commit aab4ddf

Please sign in to comment.