From 539736e316e5f141e52e51b5e4d12fc372fdd77c Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Wed, 13 Jul 2016 00:47:09 +0100 Subject: [PATCH 1/2] Add mutation-testing testing module content --- mutation-testing/.classpath | 36 ++++++++++++++++++ mutation-testing/.project | 23 +++++++++++ mutation-testing/README.md | 6 +++ mutation-testing/pom.xml | 38 +++++++++++++++++++ .../baeldung/testing/mutation/Palindrome.java | 15 ++++++++ .../mutation/test/TestPalindrome.java | 29 ++++++++++++++ pom.xml | 6 +-- 7 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 mutation-testing/.classpath create mode 100644 mutation-testing/.project create mode 100644 mutation-testing/README.md create mode 100644 mutation-testing/pom.xml create mode 100644 mutation-testing/src/main/java/com/baeldung/testing/mutation/Palindrome.java create mode 100644 mutation-testing/src/test/java/com/baeldung/mutation/test/TestPalindrome.java diff --git a/mutation-testing/.classpath b/mutation-testing/.classpath new file mode 100644 index 0000000000..d58ab93b70 --- /dev/null +++ b/mutation-testing/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mutation-testing/.project b/mutation-testing/.project new file mode 100644 index 0000000000..314dc18bfe --- /dev/null +++ b/mutation-testing/.project @@ -0,0 +1,23 @@ + + + mutation-testing + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/mutation-testing/README.md b/mutation-testing/README.md new file mode 100644 index 0000000000..6b08ece642 --- /dev/null +++ b/mutation-testing/README.md @@ -0,0 +1,6 @@ +========= + +## Mutation Testing + +### Relevant Articles: +- [Introduction to Mutation Testing Using the PITest Library](http://www.baeldung.com/????????) diff --git a/mutation-testing/pom.xml b/mutation-testing/pom.xml new file mode 100644 index 0000000000..83012ab8fe --- /dev/null +++ b/mutation-testing/pom.xml @@ -0,0 +1,38 @@ + + 4.0.0 + com.baeldung + mutation-testing + 0.1-SNAPSHOT + mutation-testing + + + org.pitest + pitest-parent + 1.1.10 + pom + + + junit + junit + 4.9 + + + + + + org.pitest + pitest-maven + 1.1.10 + + + com.baeldung.testing.mutation.* + + + com.baeldung.mutation.test.* + + + + + + \ No newline at end of file diff --git a/mutation-testing/src/main/java/com/baeldung/testing/mutation/Palindrome.java b/mutation-testing/src/main/java/com/baeldung/testing/mutation/Palindrome.java new file mode 100644 index 0000000000..0b166f1557 --- /dev/null +++ b/mutation-testing/src/main/java/com/baeldung/testing/mutation/Palindrome.java @@ -0,0 +1,15 @@ +package com.baeldung.testing.mutation; + +public class Palindrome { + + public boolean isPalindrome(String inputString) { + if (inputString.length() == 0) { + return true; + } else { + char firstChar = inputString.charAt(0); + char lastChar = inputString.charAt(inputString.length() - 1); + String mid = inputString.substring(1, inputString.length() - 1); + return (firstChar == lastChar) && isPalindrome(mid); + } + } +} diff --git a/mutation-testing/src/test/java/com/baeldung/mutation/test/TestPalindrome.java b/mutation-testing/src/test/java/com/baeldung/mutation/test/TestPalindrome.java new file mode 100644 index 0000000000..1410135883 --- /dev/null +++ b/mutation-testing/src/test/java/com/baeldung/mutation/test/TestPalindrome.java @@ -0,0 +1,29 @@ +package com.baeldung.mutation.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.baeldung.testing.mutation.Palindrome; + +public class TestPalindrome { + + @Test + public void acceptsPalindrome() { + Palindrome palindromeTester = new Palindrome(); + assertTrue(palindromeTester.isPalindrome("noon")); + } + + @Test + public void rejectsNonPalindrome(){ + Palindrome palindromeTester = new Palindrome(); + assertFalse(palindromeTester.isPalindrome("box")); + } + + @Test + public void rejectsNearPalindrome(){ + Palindrome palindromeTester = new Palindrome(); + assertFalse(palindromeTester.isPalindrome("neon")); + } +} diff --git a/pom.xml b/pom.xml index fb6d4d0761..8d18e1eaed 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ assertj - apache-cxf + core-java core-java-8 gson @@ -36,7 +36,6 @@ rest-testing resteasy - log4j spring-all spring-apache-camel @@ -79,7 +78,8 @@ xml lombok - redis + + mutation-testing From 39ebdeefdefad93ef016addc4e60caa1ff1286f7 Mon Sep 17 00:00:00 2001 From: GuenHamza Date: Wed, 13 Jul 2016 00:51:47 +0100 Subject: [PATCH 2/2] update pom.xml --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8d18e1eaed..562aaf896b 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ assertj - + apache-cxf core-java core-java-8 gson @@ -36,6 +36,7 @@ rest-testing resteasy + log4j spring-all spring-apache-camel @@ -78,6 +79,7 @@ xml lombok + redis mutation-testing