Java Reference
In-Depth Information
Figure B.2
Results from executing the tests, including the custom matcher
Listing B.11
Test case using our custom matcher
[...]
import static
org.hamcrest.core.Is.is;
import static
com.manning.junitbook.appD.custom.matchers.
IsStrongPassword.isStrongPassword;
import static
com.manning.junitbook.appD.custom.matchers.
IsStrongPassword.strongPassword;
B
public class
TestIsPasswordStrongUsingMatcher {
@Test
public void
testIsPasswordStrongIsStrong() {
final
String pass = "!abcde0";
C
assertThat( pass, isStrongPassword() );
assertThat( pass, is( strongPassword() ) );
}
@Test( expected = java.lang.AssertionError.class )
public voi
d testIsPasswordStrongTooShort() {
final
String shortPass = "abcde";