Java Reference
In-Depth Information
assertThat( shortPass, isStrongPassword() );
assertThat( shortPass, is( strongPassword() ) );
}
@Test( expected = java.lang.AssertionError.class )
public void
testIsPasswordStrongContainsNoSpecialCharacter() {
final
String noSpecialCharacterPass = "abcdef0";
assertThat( noSpecialCharacterPass, isStrongPassword() );
assertThat( noSpecialCharacterPass, is( strongPassword() ) );
}
@Test( expected = java.lang.AssertionError.class )
public void
testIsPasswordStrongContainsNoDigit() {
final
String noDigitPass = "abcdef!";
assertThat( noDigitPass, isStrongPassword() );
assertThat( noDigitPass, is( strongPassword() ) );
}
@Test( expected = java.lang.AssertionError.class )
public void
testIsPasswordStrongIsNull() {
final
String nullPass = null;
assertThat( nullPass, isStrongPassword() );
assertThat( nullPass, is( strongPassword() ) );
}
}
In
B
we import the matchers that we want to use as static imports. Notice that we
import our matchers the exact same way as we would any of the Hamcrest core match-
ers. Then we can use any of them, again as we would any Hamcrest matcher
C
.
The code is nice and clear now, isn't it?