Ruby\'s Test::Unit
has a nice assert_matches
method that can be used in unit tests to assert that a regex matches a string.
Is there anythi
You can use Hamcrest and jcabi-matchers:
import static com.jcabi.matchers.RegexMatchers.matchesPattern;
import static org.junit.Assert.assertThat;
assertThat("test", matchesPattern("[a-z]+"));
More details here: Regular Expression Hamcrest Matchers.
You will need these two dependencies in classpath:
org.hamcrest
hamcrest-core
1.3
test
com.jcabi
jcabi-matchers
1.3
test