Skip to content

Commit 6ffc6ff

Browse files
Merge pull request eugenp#495 from GuenHamza/master
[BAEL 145] - Add mutation testing module
2 parents b426599 + 39ebdee commit 6ffc6ff

7 files changed

Lines changed: 149 additions & 0 deletions

File tree

‎mutation-testing/.classpath‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>

‎mutation-testing/.project‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>mutation-testing</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>

‎mutation-testing/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=========
2+
3+
## Mutation Testing
4+
5+
### Relevant Articles:
6+
- [Introduction to Mutation Testing Using the PITest Library](http://www.baeldung.com/????????)

‎mutation-testing/pom.xml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>mutation-testing</artifactId>
6+
<version>0.1-SNAPSHOT</version>
7+
<name>mutation-testing</name>
8+
<dependencies>
9+
<dependency>
10+
<groupId>org.pitest</groupId>
11+
<artifactId>pitest-parent</artifactId>
12+
<version>1.1.10</version>
13+
<type>pom</type>
14+
</dependency>
15+
<dependency>
16+
<groupId>junit</groupId>
17+
<artifactId>junit</artifactId>
18+
<version>4.9</version>
19+
</dependency>
20+
</dependencies>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.pitest</groupId>
25+
<artifactId>pitest-maven</artifactId>
26+
<version>1.1.10</version>
27+
<configuration>
28+
<targetClasses>
29+
<param>com.baeldung.testing.mutation.*</param>
30+
</targetClasses>
31+
<targetTests>
32+
<param>com.baeldung.mutation.test.*</param>
33+
</targetTests>
34+
</configuration>
35+
</plugin>
36+
</plugins>
37+
</build>
38+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.baeldung.testing.mutation;
2+
3+
public class Palindrome {
4+
5+
public boolean isPalindrome(String inputString) {
6+
if (inputString.length() == 0) {
7+
return true;
8+
} else {
9+
char firstChar = inputString.charAt(0);
10+
char lastChar = inputString.charAt(inputString.length() - 1);
11+
String mid = inputString.substring(1, inputString.length() - 1);
12+
return (firstChar == lastChar) && isPalindrome(mid);
13+
}
14+
}
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.baeldung.mutation.test;
2+
3+
import static org.junit.Assert.assertFalse;
4+
import static org.junit.Assert.assertTrue;
5+
6+
import org.junit.Test;
7+
8+
import com.baeldung.testing.mutation.Palindrome;
9+
10+
public class TestPalindrome {
11+
12+
@Test
13+
public void acceptsPalindrome() {
14+
Palindrome palindromeTester = new Palindrome();
15+
assertTrue(palindromeTester.isPalindrome("noon"));
16+
}
17+
18+
@Test
19+
public void rejectsNonPalindrome(){
20+
Palindrome palindromeTester = new Palindrome();
21+
assertFalse(palindromeTester.isPalindrome("box"));
22+
}
23+
24+
@Test
25+
public void rejectsNearPalindrome(){
26+
Palindrome palindromeTester = new Palindrome();
27+
assertFalse(palindromeTester.isPalindrome("neon"));
28+
}
29+
}

‎pom.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080

8181
<module>lombok</module>
8282
<module>redis</module>
83+
84+
<module>mutation-testing</module>
8385
</modules>
8486

8587
</project>

0 commit comments

Comments
 (0)