This commit is contained in:
2023-05-15 10:38:18 +02:00
parent 99a3f97555
commit 4c2939df42
12 changed files with 392 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
CalculatorTest1 est un exemple de test pour la classe Calculator utilisant junit4.
Comment vérifier qu'on lance bien une exception?
*/
public class CalculatorTest1 {
// un test pour Junit4 qui cherche à vérifier qu'il y a bien une exception
@Test(expected = NumberFormatException.class)
public void doesNotEvaluateBadExpression() {
Calculator calculator = new Calculator();
int sum = calculator.evaluate("1 +2+3");//notez l'espace qui va génèrez une exception
}
}