Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. package blog;
  2.  
  3.  
  4. import org.junit.Assert;
  5. import org.junit.Before;
  6. import org.junit.Test;
  7.  
  8. /**
  9. * Classe que testará a Classe Usuario
  10. * @author Karina Silva
  11. * @version 1.01 8 de junho de 2009
  12. */
  13. public class UsuarioTest {
  14.  
  15. Usuario usuario1, usuario2, usuario3, usuario4;
  16.  
  17. /**
  18. * Testa se o usuario está sendo criado
  19. * @throws Exception
  20. */
  21. @Before
  22. public void setUp() throws Exception {
  23.  
  24. usuario1 = new Usuario("Karina","123a45");
  25. usuario2 = new Usuario("Raquel", "789b");
  26. usuario3 = new Usuario("David", "12345z");
  27. usuario4 = new Usuario("Daniel","12345x");
  28.  
  29. }
  30.  
  31. /**
  32. * Testa se o login é nulo
  33. * @throws Exception
  34. */
  35. @Test(expected=Exception.class)
  36. public void testLoginNull() throws Exception {
  37.  
  38. usuario1 = new Usuario(null, "123a45");
  39. usuario2 = new Usuario(null,"789b");
  40. usuario3 = new Usuario(null,"12345z");
  41. usuario4 = new Usuario(null,"12345x");
  42.  
  43.  
  44. }
  45.  
  46. @Test(expected=Exception.class)
  47. public void testLoginVazio() throws Exception {
  48.  
  49. usuario1 = new Usuario("", "123a45");
  50. usuario2 = new Usuario("", "789b");
  51.  
  52.  
  53. }
  54.  
  55. @Test(expected=Exception.class)
  56. public void testSenhaNull() throws Exception {
  57.  
  58. usuario1 = new Usuario("Karina", null);
  59. usuario2 = new Usuario("Raquel", null);
  60.  
  61. }
  62.  
  63. @Test(expected=Exception.class)
  64. public void testSenhaVazia() throws Exception {
  65.  
  66. usuario1 = new Usuario("Karina", "");
  67. usuario2 = new Usuario("Raquel", "");
  68.  
  69. }
  70.  
  71. @Test(expected=Exception.class)
  72. public void testPerfilValido() throws Exception {
  73.  
  74. Assert.assertEquals("errado", usuario2.getPerfil());
  75. Assert.assertEquals("Usuario deveria ter um perfil", usuario1
  76. .perfil(usuario2.getPerfil()), null);
  77.  
  78. }
  79. }
Add Comment
Please, Sign In to add comment