Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. package p2.exemplos.testes;
  2.  
  3. import org.junit.Assert;
  4. import org.junit.Before;
  5. import org.junit.Test;
  6.  
  7. import p2.exemplos.Pessoa;
  8.  
  9. public class TestaPessoa {
  10.    
  11.     private Pessoa maria;
  12.     private Pessoa jose;
  13.     private Pessoa joao;
  14.    
  15.     @Before
  16.     public void criaPessoas() throws Exception {
  17.         maria = new Pessoa("Maria", "111");
  18.         jose = new Pessoa("Jose");
  19.         joao = new Pessoa("Joao", "113");
  20.     }
  21.    
  22.     @Test
  23.     public void testeMaria() throws Exception {
  24.         Assert.assertEquals("Nome errado", "Maria", maria.getNome());
  25.         Assert.assertEquals("CPF errado", "111", maria.getCPF());
  26.         maria.setNome("Maria da Silva e Silva");
  27.         Assert.assertEquals("Nome errado", "Maria da Silva e Silva", maria.getNome());
  28.     }
  29.    
  30.     @Test
  31.     public void testeJose() throws Exception {
  32.         Assert.assertEquals("Nome errado", "Jose", jose.getNome());
  33.         Assert.assertEquals("CPF errado", "", jose.getCPF());
  34.         jose.setCPF("112");
  35.         Assert.assertEquals("CPF errado", "112", jose.getCPF());
  36.     }
  37.    
  38.     @Test public void testeJoao() throws Exception {
  39.         Pessoa joao2 = new Pessoa("Joao", "113");
  40.         Assert.assertTrue("Pessoas diferentes", joao.equals(joao2));
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement