Skip to content

Commit

Permalink
Merge pull request #448 from sarahBuisson/aggregationModule
Browse files Browse the repository at this point in the history
Adds additional report-aggregate-module mojo
  • Loading branch information
hcoles authored Apr 25, 2018
2 parents a211fd7 + 32c7e90 commit 1c69459
Show file tree
Hide file tree
Showing 11 changed files with 428 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pitest-maven-verification/src/test/java/org/pitest/PitMojoIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,40 @@ public void shouldGenerateSiteReportWithSingleTimestampedHtmlReport()
verifyPitReportTest(testDir);
}

/*
* Verifies that running PIT compute the result of the two sub-module
*/
@Test
public void shouldComputeReportOfTheSubModule()
throws Exception {
//Given
File testDir = prepare("/pit-sub-module");

verifier.executeGoal("test");
verifier.executeGoal("org.pitest:pitest-maven:mutationCoverage");


//When
verifier.executeGoal("org.pitest:pitest-maven:report-aggregate-module");

//Then
File siteParentDir = buildFilePath(testDir, "target", "pit-reports");
assertThat(buildFilePath(siteParentDir, "index.html")).exists();
String projectReportsHtmlContents = FileUtils
.readFileToString(buildFilePath(testDir, "target", "pit-reports",
"index.html"));

assertTrue("miss data of subModule 1",
projectReportsHtmlContents
.contains("<a href=\"./org.example1/index.html\">org.example1</a>"));

assertTrue("miss data of subModule 2",

projectReportsHtmlContents
.contains("<a href=\"./org.example2/index.html\">org.example2</a>"));

}

/*
* Verifies that, when multiple timestamped PIT reports have been generated,
* only the latest report is copied to the site reports directory. This test
Expand Down Expand Up @@ -361,6 +395,7 @@ public void shouldWorkWithYatspec() throws Exception {
assertThat(actual).doesNotContain("status='RUN_ERROR'");
}


private static String readResults(File testDir) throws IOException {
File mutationReport = new File(testDir.getAbsoluteFile() + File.separator
+ "target" + File.separator + "pit-reports" + File.separator
Expand Down Expand Up @@ -515,4 +550,5 @@ private void verifyPitReportTest(File testDir) throws Exception {
.contains("<a href=\"pit-reports/index.html\" title=\"PIT Test Report\">PIT Test Report</a>"));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>pit-parent-module</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>pit-parent-module</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>${pit.version}</version>
<configuration>
<timestampedReports>false</timestampedReports>
<outputFormats>
<outputFormat>HTML</outputFormat>
<!-- xml is used by the report aggregate -->
<outputFormat>XML</outputFormat>
</outputFormats>
<!-- exportLineCoverage is used by the report aggregate -->
<exportLineCoverage>true</exportLineCoverage>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>


<properties>
<junit.version>4.8.1</junit.version>
</properties>
<modules>
<module>sub-module-1</module>
<module>sub-module-2</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>pit-parent-module</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.pitest</groupId>
<artifactId>sub-module-1</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sub-module 1</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

</plugins>
</build>
<properties>
<junit.version>4.8.1</junit.version>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.example1;

public class SystemUnderTest {

private int aNumber = 0;

public SystemUnderTest() {
super();

int a = 25;
int b = 10;
if (a < b) {
aNumber = 10;
} else {
aNumber = -25;
}
}

public String toString() {
return "SystemUnderTest";
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.example1;

import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertNotNull;

import java.io.File;
import org.junit.Test;

public class FileOpeningTest {

@Test
public void testOpenFileRelativeToWorkingDirectory() {
SystemUnderTest sut = new SystemUnderTest();

File file = new File("src/test/resources/fixture.file");
assertTrue(file.exists());
assertNotNull(sut.toString());
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test123
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.example</groupId>
<artifactId>pit-parent-module</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.pitest</groupId>
<artifactId>sub-module-2</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sub module2</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

</plugins>
</build>
<properties>
<junit.version>4.8.1</junit.version>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.example2;

public class SystemUnderTest {

private int aNumber = 0;

public SystemUnderTest() {
super();

int a = 25;
int b = 10;
if (a < b) {
aNumber = 10;
} else {
aNumber = -25;
}
}

public String toString() {
return "SystemUnderTest";
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.example2;

import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.assertNotNull;

import java.io.File;
import org.junit.Test;

public class FileOpeningTest {

@Test
public void testOpenFileRelativeToWorkingDirectory() {
SystemUnderTest sut = new SystemUnderTest();

File file = new File("src/test/resources/fixture.file");
assertTrue(file.exists());
assertNotNull(sut.toString());
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test123
Loading

0 comments on commit 1c69459

Please sign in to comment.