Skip to content

Instantly share code, notes, and snippets.

@Senemix29
Last active August 7, 2021 23:51
Show Gist options
  • Select an option

  • Save Senemix29/fd11dbc12614d29e9ae5c9b5c9b55dc2 to your computer and use it in GitHub Desktop.

Select an option

Save Senemix29/fd11dbc12614d29e9ae5c9b5c9b55dc2 to your computer and use it in GitHub Desktop.
A test class to be used as an example at a medium post about testing
class NameValidatorTest {
private val nameValidator = NameValidator()
@Test
fun 'isValid should return false when name is empty'() {
val name = ""
assertEquals(false, nameValidator.isValid(name))
}
@Test
fun 'isValid should return false when name lenght is lower than MIN_NAME_LENGTH'() {
val name = "El"
assertEquals(false, nameValidator.isValid(name))
}
@Test
fun 'isValid should return true when name is valid'() {
val name = "Messi"
assertEquals(true, nameValidator.isValid(name))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment