Created
November 17, 2010 19:36
-
-
Save alexandregama/703910 to your computer and use it in GitHub Desktop.
TDD simples e prático, Parte III
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
//Este código faz parte do artigo em http://alexandregama.wordpress.com | |
//Classe de Teste utilizando JUnit 4 | |
package artigotdd.calculadora.teste; | |
import static org.junit.Assert.*; | |
import org.junit.Test; | |
public class CalculadoraTeste { | |
@Test | |
public void deveriaSomarDoisValoresPassados() throws Exception { | |
Calculadora calculadora = new Calculadora(); | |
int valorA = 1; | |
int valorB = 2; | |
int soma = calculadora.soma(valorA, valorB); | |
assertEquals(3, soma); | |
} | |
@Test | |
public void deveriaSubtrairDoisValoresPassados() throws Exception { | |
Calculadora calculadora = new Calculadora(); | |
int valorA = 5; | |
int valorB = 2; | |
int subtracao = calculadora.subtrai(valorA, valorB); | |
assertEquals(3, subtracao); | |
} | |
} | |
//Classe com a implementação | |
package artigotdd.calculadora.teste; | |
public class Calculadora { | |
public int soma(int valorA, int valorB) { | |
return valorA + valorB; | |
} | |
public int subtrai(int valorA, int valorB) { | |
return valorA - valorB; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment