Created
April 20, 2014 07:27
-
-
Save samueltcsantos/11107564 to your computer and use it in GitHub Desktop.
Testando a classe Produto.
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
package com.java.junit3x; | |
import com.java.junit.Produto; | |
import junit.framework.TestCase; | |
/** | |
* Tests JUnit3.x para a classe Produto. | |
* | |
* @author Samuel T. C. Santos | |
* | |
*/ | |
public class ProdutoTest extends TestCase { | |
Produto produto; | |
//inicializa o objeto antes de executar cada teste | |
public void setUp(){ | |
produto = new Produto(); | |
} | |
//apos executar cada teste torna o objeto null novamente. | |
public void tearDown(){ | |
produto = null; | |
} | |
public void testNaoDeveSerNull(){ | |
assertNotNull(produto); | |
} | |
public void testDeveSerDiferenteDeOutroProdutoInicializado(){ | |
assertNotSame(produto, new Produto()); | |
} | |
public void testDeveSerIgualQuandoFizerReferenciaParaOMesmoObjeto(){ | |
Produto produtoClone = produto; | |
assertSame(produto,produtoClone); | |
} | |
public void testMostreQueMesmosValoresNaoSignificaMesmoObjeto(){ | |
Produto p1 = new Produto("x0011xk009","sandalia havainas","havainas",16.99); | |
Produto p2 = new Produto("x0011xk009","sandalia havainas","havainas",16.99); | |
assertNotSame(p1, p2); | |
//porem se armazenam os mesmos dados sao equals | |
assertTrue(p1.equals(p2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment