Created
June 29, 2020 19:48
-
-
Save catalinsgh/51255d02b84256d0d695caaae07f73d4 to your computer and use it in GitHub Desktop.
PasswordValidatorTest using ParameterizedTest
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
internal class PasswordValidatorTest { | |
private val validator = PasswordValidator() | |
@ParameterizedTest(name = "given \"{0}\", when validating the password, then it should return {1}") | |
@MethodSource("passwordArguments") | |
fun `given input password, when validating it, then is should return if it is valid`( | |
password: String, | |
expected: Boolean | |
) { | |
val actual = validator.isValid(password) | |
assertThat(actual).isEqualTo(expected) | |
} | |
private companion object { | |
@JvmStatic | |
fun passwordArguments() = Stream.of( | |
Arguments.of("Test123!", true), | |
Arguments.of("#tesT12!", true), | |
Arguments.of("12Es@t123", true), | |
Arguments.of("test123!", false), | |
Arguments.of("t ", false), | |
Arguments.of(" ", false) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment