TP-metaprogrammation-test/TP4/MonnaieTest.java

40 lines
832 B
Java
Raw Normal View History

2021-12-03 14:47:29 +00:00
/** Classe regroupant les tests unitaires de la classe Monnaie. */
public class MonnaieTest {
protected Monnaie m1;
protected Monnaie m2;
protected Monnaie m3;
@Avant
public void debut() {
this.m1 = new Monnaie(5, "euro");
this.m2 = new Monnaie(7, "euro");
}
@UnTest(enabled = false)
public void ajouter() throws DeviseInvalideException {
m1.ajouter(m2);
Assert.assertTrue(m1.getValeur() == 12);
}
@UnTest
public void retrancher() throws DeviseInvalideException {
m1.retrancher(m2);
Assert.assertTrue(m1.getValeur() == -2);
}
@UnTest(expected = NullPointerException.class)
public void retrancher2() throws DeviseInvalideException {
m1.retrancher(m2);
m3.ajouter(m1);
Assert.assertTrue(m1.getValeur() == 1234567890);
}
@Apres
public void rwwwwit() {
this.m1 = null;
this.m2 = null;
}
}