Created
July 18, 2021 09:47
-
-
Save sergio-sastre/8a5ec8bdbf3dabcab8743ef3a59cb98f to your computer and use it in GitHub Desktop.
Multiplying the quality of your Unit Tests (Part2) with PBT - JUnit5 Password Validator Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val passwordValidator = PasswordValidator( | |
ContainsUpperCaseLetterValidator(), | |
MinCharsValidator(6), | |
ContainsDigitValidator(), | |
ContainsLowerCaseLetterValidator(), | |
NoBlanksValidator() | |
) | |
@DisplayName("PasswordValidator for invalid passwords") | |
@ParameterizedTest(name = "When password is \"{0}\", the error contains \"{1}\"") | |
@CsvSource( | |
"123456, no upper case letters", | |
"ABCDEF, no digits", | |
"HELLO, no lower case letters", | |
"1234A, contains less than 6 chars", | |
"12 3 456, contains blanks" | |
) | |
fun testPasswordValidatorRight(password: String?, expectedError: String?) { | |
val actualError = passwordValidator.validate(password) | |
assertThat(actualError).contains(expectedError) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment