Skip to content

Instantly share code, notes, and snippets.

@catalinsgh
Created June 29, 2020 19:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save catalinsgh/51255d02b84256d0d695caaae07f73d4 to your computer and use it in GitHub Desktop.
Save catalinsgh/51255d02b84256d0d695caaae07f73d4 to your computer and use it in GitHub Desktop.
PasswordValidatorTest using ParameterizedTest
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