Skip to content

Commit

Permalink
cross module example project
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Nov 1, 2024
1 parent 5586542 commit be303c6
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 0 deletions.
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>

<artifactId>cross-tests-code</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>cross-tests-code</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.8</source>
<target>1.8</target>
</configuration>
</plugin>

</plugins>
</build>
<properties>
<junit.version>4.13.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,30 @@
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 int getNumber() {
return aNumber;
}

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

public boolean isActive() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<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>

<artifactId>cross-tests-tests</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>cross-tests-tests</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>cross-tests-code</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

</plugins>
</build>
<properties>
<junit.version>4.13.1</junit.version>
</properties>
</project>
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,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,19 @@
package org.example2;

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

import org.junit.Test;

public class SystemUnderTestTest {

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

int result = sut.getNumber();
assertTrue(result == -25);
}


}
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,61 @@
<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.8</source>
<target>1.8</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>
<aggregatedTestStrengthThreshold>26</aggregatedTestStrengthThreshold>
<aggregatedMutationThreshold>20</aggregatedMutationThreshold>
<aggregatedMaxSurviving>6</aggregatedMaxSurviving>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>


<properties>
<junit.version>4.13.1</junit.version>
</properties>
<modules>
<module>cross-tests-code</module>
<module>cross-tests-tests</module>
</modules>
</project>

0 comments on commit be303c6

Please sign in to comment.