Last active
August 29, 2015 14:20
-
-
Save flisboac/61c5af61d457c9042422 to your computer and use it in GitHub Desktop.
Exemplo TDD/BDD
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
Caso de uso: Usuário realiza cadastro de outros usuários | |
Descrição: ... | |
Cenário: Usuário entra na tela de cadastro para editar | |
Quando: Usuário digita e-mail *@localhost | |
Então: Falhar | |
Cenário: Fornecendo idade | |
Se idade for maior que 85 | |
Então solicitar idade menor |
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
public class Usuario { | |
// fie | |
} | |
public class UsuarioDLO { | |
public List<Usuario> buscarPorSetor(String setor) { | |
// ... | |
} | |
} | |
// TDD ---------------------------------- | |
// Test Driven Development | |
// BDD - Behaviour Driven Development | |
public class UsuarioDLOTest { | |
private UsuarioDLO usuarioDLO; | |
public void setup() { | |
usuarioDLO = new UsuarioDLO(); | |
usuarioDLO.setEntityManager(...); | |
} | |
public void testBuscarPorSetor() { | |
String setorTeste = "Administracao"; | |
List<Usuario> usuarios = usuarioDLO.buscarPorSetor(setorTeste); | |
if (usuarios == null || usuarios.isEmpty()) { | |
// FALHOU | |
} | |
} | |
@When("idade for maior que %d anos") | |
public testSalvarUsuarioComIdade(int idade) { | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment