Created
          June 30, 2020 18:40 
        
      - 
      
- 
        Save catalinsgh/59cb409ecf10d76611e844390195b09a to your computer and use it in GitHub Desktop. 
    PasswordValidatorTest using dynamic tests
  
        
  
    
      This file contains hidden or 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() | |
| @TestFactory | |
| fun `given input password, when validating it, then is should return if it is valid`() = | |
| listOf( | |
| "Test123!" to true, | |
| "#tesT12!" to true, | |
| "12Es@t123" to true, | |
| "test123!" to false, | |
| "t " to false, | |
| " " to false | |
| ).map { (password, expected) -> | |
| dynamicTest( | |
| "given \"$password\", " + | |
| "when validating the password, " + | |
| "then it should be reported as ${if (expected) "valid" else "invalid"}" | |
| ) { | |
| val actual = validator.isValid(password) | |
| assertThat(actual).isEqualTo(expected) | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment