This repository contains a Java class MyString.java
which implements two Java methods:indexOfString() and replace(). The implementation follows the principles of test-driven development (TDD) and the philosophy of specification-based testing approach.
The following methods have been implemented in the MyString.java
class:
-
indexOfString(String s1, String s2, int pos)
: The method receives two strings and an integer to find the first starting index i such that s2 starts at i in s1 and i >= pos. -
replace(String s, String s1, String s2)
: The method receives three strings and replaces all the occurrences of s1 with s2 in the string s.
The Main
class show how to use the MyString.java
class, follow these steps to run it:
-
Clone the repository to your local machine.
-
Run class by your IDE derectly OR
-
Run following commend:
mvn exec:java
- The test can be ran with:
mvn test
- You can confiure the converage threshold with following commend to get the coverage report, then go to target/pit-reports to see it:
mvn clean test-compile org.pitest:pitest-maven:mutationCoverage -DcoverageThreshold=<default:95> -DmutationThreshold=<default:95>
The line converage of Mystring is 100% and mutant converage is 95%.