Skip to content

Commit

Permalink
Partly fix constructor coverage and junit classpath issues (#81)
Browse files Browse the repository at this point in the history
* Partly fix constructor coverage and junit classpath issues

Signed-off-by: André Silva <[email protected]>

* Fix junit-jupiter-params dependency

Signed-off-by: André Silva <[email protected]>

* Fix dependencies and test results

Signed-off-by: André Silva <[email protected]>

* Set scope for junit dependencies

Signed-off-by: André Silva <[email protected]>

* Fix junit dependencies again

Signed-off-by: André Silva <[email protected]>
  • Loading branch information
andre15silva authored Aug 11, 2021
1 parent 656be0f commit 14585dd
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 83 deletions.
67 changes: 29 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,11 @@
</repositories>

<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
</dependency>

<!-- dependencies for the junit classpah -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.2</version>
<scope>test</scope>
<version>4.13.2</version>
</dependency>

<dependency>
Expand All @@ -82,12 +70,25 @@
<version>5.3.2</version>
</dependency>

<!-- regular dependencies -->
<dependency>
<groupId>eu.stamp-project</groupId>
<artifactId>test-runner</artifactId>
<version>3.0.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>9.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
Expand All @@ -101,27 +102,21 @@
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.8.1</version>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.6.1</version>
</dependency>

<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>9.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.7</version>
</dependency>

<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>4.6.1</version>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.4.0</version>
</dependency>

<!-- for testing System.exit -->
Expand All @@ -132,16 +127,12 @@
<scope>test</scope>
</dependency>

<!-- for mocks -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.7</version>
</dependency>

<dependency>
<groupId>net.sf.supercsv</groupId>
<artifactId>super-csv</artifactId>
<version>2.4.0</version>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.2</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.spoonlabs.flacoco.cli.export;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import fr.spoonlabs.flacoco.api.Suspiciousness;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected String computeClasspath() {
String junitClasspath;
String jacocoClassPath;

junitClasspath = mavenHome + "junit/junit/4.12/junit-4.12.jar" + File.pathSeparatorChar
junitClasspath = mavenHome + "junit/junit/4.13.2/junit-4.13.2.jar" + File.pathSeparatorChar
+ mavenHome + "org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" + File.pathSeparatorChar
+ mavenHome + "org/junit/jupiter/junit-jupiter-api/5.3.2/junit-jupiter-api-5.3.2.jar" + File.pathSeparatorChar
+ mavenHome + "org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar" + File.pathSeparatorChar
Expand Down
56 changes: 42 additions & 14 deletions src/test/java/fr/spoonlabs/flacoco/api/FlacocoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testExampleFL1SpectrumBasedOchiaiDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(4, susp.size());
assertEquals(6, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -68,6 +68,8 @@ public void testExampleFL1SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand Down Expand Up @@ -121,7 +123,7 @@ public void testExampleFL1SpectrumBasedOchiaiDefaultModeIncludeZero() {
}

// all lines are returned
assertEquals(8, susp.size());
assertEquals(10, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -132,6 +134,8 @@ public void testExampleFL1SpectrumBasedOchiaiDefaultModeIncludeZero() {

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);

// Lines with no failing test executing them have a 0.0 score
assertEquals(0.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@11").getScore(), 0);
Expand Down Expand Up @@ -165,14 +169,16 @@ public void testExampleFL1SpectrumBasedOchiaiDefaultModeManualTestConfig() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(4, susp.size());
assertEquals(6, susp.size());

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

// Line executed by a mix of failing and passing
assertEquals(0.70, susp.get("fr/spoonlabs/FLtest1/Calculator@-@14").getScore(), 0.01);
assertEquals(0.57, susp.get("fr/spoonlabs/FLtest1/Calculator@-@12").getScore(), 0.01);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
Expand Down Expand Up @@ -200,7 +206,7 @@ public void testExampleFL2SpectrumBasedOchiaiDefaultMode() {
System.out.println("susp " + line + " " + susp.get(line));
}

assertEquals(6, susp.keySet().size());
assertEquals(8, susp.keySet().size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@21").getScore(), 0);
Expand All @@ -213,6 +219,8 @@ public void testExampleFL2SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@12").getScore(), 0.01);
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0.01);
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0.01);
}

@Test
Expand All @@ -233,7 +241,7 @@ public void testExampleFL3SpectrumBasedOchiaiDefaultMode() {
System.out.println("susp " + line + " " + susp.get(line));
}

assertEquals(5, susp.keySet().size());
assertEquals(7, susp.keySet().size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@21").getScore(), 0);
Expand All @@ -245,6 +253,8 @@ public void testExampleFL3SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@12").getScore(), 0.01);
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0.01);
assertEquals(0.44, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0.01);
}

@Test
Expand All @@ -267,7 +277,7 @@ public void testExampleFL1SpectrumBasedOchiaiCoverTestsDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(6, susp.size());
assertEquals(8, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -280,6 +290,8 @@ public void testExampleFL1SpectrumBasedOchiaiCoverTestsDefaultMode() {
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/CalculatorTest@-@9").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/CalculatorTest@-@7").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand All @@ -296,7 +308,8 @@ public void testExampleFL1SpectrumBasedOchiaiSpoonMode() {
// Run default mode
Map<CtStatement, Suspiciousness> susp = flacoco.runSpoon();

assertEquals(4, susp.size());
// The two lines of the (empty) constructor get mapped to the same CtStatement
assertEquals(5, susp.size());

for (CtStatement ctStatement : susp.keySet()) {
System.out.println("" + ctStatement + " " + susp.get(ctStatement));
Expand All @@ -317,6 +330,7 @@ public void testExampleFL1SpectrumBasedOchiaiSpoonMode() {
break;
// Lines executed by all test
case 10:
case 5:
assertEquals(0.5, susp.get(ctStatement).getScore(), 0);
break;
}
Expand Down Expand Up @@ -741,7 +755,7 @@ public void testExampleFL7SpectrumBasedOchiaiDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(4, susp.size());
assertEquals(6, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -752,6 +766,8 @@ public void testExampleFL7SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand All @@ -777,7 +793,7 @@ public void testExampleFL8SpectrumBasedOchiaiDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(4, susp.size());
assertEquals(6, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -788,6 +804,8 @@ public void testExampleFL8SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand All @@ -814,7 +832,7 @@ public void testExampleFL8SpectrumBasedOchiaiCoverTestsDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(6, susp.size());
assertEquals(8, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -827,6 +845,8 @@ public void testExampleFL8SpectrumBasedOchiaiCoverTestsDefaultMode() {
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/CalculatorTest@-@9").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/CalculatorTest@-@7").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand All @@ -847,7 +867,8 @@ public void testExampleFL8SpectrumBasedOchiaiSpoonMode() {
// Run default mode
Map<CtStatement, Suspiciousness> susp = flacoco.runSpoon();

assertEquals(4, susp.size());
// The two lines of the (empty) constructor get mapped to the same CtStatement
assertEquals(5, susp.size());

for (CtStatement ctStatement : susp.keySet()) {
System.out.println("" + ctStatement + " " + susp.get(ctStatement));
Expand All @@ -868,6 +889,7 @@ public void testExampleFL8SpectrumBasedOchiaiSpoonMode() {
break;
// Lines executed by all test
case 10:
case 5:
assertEquals(0.5, susp.get(ctStatement).getScore(), 0);
break;
}
Expand Down Expand Up @@ -896,7 +918,7 @@ public void testExampleFL9SpectrumBasedOchiaiDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(4, susp.size());
assertEquals(6, susp.size());

// Line executed only by the failing
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@15").getScore(), 0);
Expand All @@ -907,6 +929,8 @@ public void testExampleFL9SpectrumBasedOchiaiDefaultMode() {

// Lines executed by all test
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0);
assertEquals(0.5, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0);
}

@Test
Expand All @@ -927,7 +951,8 @@ public void testExampleFL9SpectrumBasedOchiaiSpoonMode() {
// Run default mode
Map<CtStatement, Suspiciousness> susp = flacoco.runSpoon();

assertEquals(4, susp.size());
// The two lines of the (empty) constructor get mapped to the same CtStatement
assertEquals(5, susp.size());

for (CtStatement ctStatement : susp.keySet()) {
System.out.println("" + ctStatement + " " + susp.get(ctStatement));
Expand All @@ -948,6 +973,7 @@ public void testExampleFL9SpectrumBasedOchiaiSpoonMode() {
break;
// Lines executed by all test
case 10:
case 5:
assertEquals(0.5, susp.get(ctStatement).getScore(), 0);
break;
}
Expand All @@ -972,7 +998,7 @@ public void testExampleFL11SpectrumBasedOchiaiDefaultMode() {
System.out.println("" + line + " " + susp.get(line));
}

assertEquals(6, susp.size());
assertEquals(8, susp.size());

// Line executed by all failing test cases
assertEquals(1.0, susp.get("fr/spoonlabs/FLtest1/Calculator@-@14").getScore(), 0.0);
Expand All @@ -987,6 +1013,8 @@ public void testExampleFL11SpectrumBasedOchiaiDefaultMode() {

// Line executed by all tests (2 passing, 2 failing)
assertEquals(0.70, susp.get("fr/spoonlabs/FLtest1/Calculator@-@10").getScore(), 0.01);
assertEquals(0.70, susp.get("fr/spoonlabs/FLtest1/Calculator@-@5").getScore(), 0.01);
assertEquals(0.70, susp.get("fr/spoonlabs/FLtest1/Calculator@-@6").getScore(), 0.01);
}

/**
Expand Down
Loading

0 comments on commit 14585dd

Please sign in to comment.