Custom hamcrest matcher that counts occurrences of a substring.
The current release is 0.0.5.
import static io.zinx.hamcrest.string.pattern.OccurrenceMatcher.hasOccurrenceCount;
...
@Test
public void testMatch() {
String item = "Fred,Joe,John,Tim";
String searchString = ",";
int count = 3;
assertThat(item, hasOccurrenceCount(count, searchString));
}
The code uses the Apache Commons Lang3 library.
- Clone the repo from github.
- gradlew build
The artifact is available on https://jitpack.io/.
To include it using gradle, do the following:
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.github.zinx-io:hamcrest-string-matcher:0.0.6'
}
To include it using maven, do the following:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.zinx-io</groupId>
<artifactId>hamcrest-string-matcher</artifactId>
<version>0.0.6</version>
</dependency>