diff --git a/src/main/java/fr/nancy/iut/CalcEngineTester.java b/src/main/java/fr/nancy/iut/CalcEngineTester.java deleted file mode 100755 index dc31dd95a93608f8a4607d855560754034274ac0..0000000000000000000000000000000000000000 --- a/src/main/java/fr/nancy/iut/CalcEngineTester.java +++ /dev/null @@ -1,74 +0,0 @@ -package fr.nancy.iut; - -/** - * Test the CalcEngine class. - * - * @author Hacker T. Largebrain - * @version 1.0 - */ -// package calculator; - -public class CalcEngineTester -{ - // The engine to be tested. - private CalcEngine engine; - - /** - * Constructor for objects of class CalcEngineTester - */ - public CalcEngineTester() - { - engine = new CalcEngine(); - } - - /** - * Test everything. - */ - public void testAll() - { - System.out.println("Testing the addition operation."); - System.out.println("The result is: " + testPlus()); - System.out.println("Testing the subtraction operation."); - System.out.println("The result is: " + testMinus()); - System.out.println("All tests passed."); - } - - /** - * Test the plus operation of the engine. - * @return the result of calculating 3+4. - */ - public int testPlus() - { - // Make sure the engine is in a valid starting state. - engine.clear(); - // Simulate the key presses: 3 + 4 = - engine.numberPressed(3); - engine.plus(); - engine.numberPressed(4); - engine.equals(); - // Return the result, which should be 7. - return engine.getDisplayValue(); - } - - /** - * Test the minus operation of the engine. - * @return the result of calculating 9 - 4. - */ - public int testMinus() - { - // Make sure the engine is in a valid starting state. - engine.clear(); - // Simulate the presses: 9 - 4 = - engine.numberPressed(9); - engine.minus(); - engine.numberPressed(4); - engine.equals(); - // Return the result, which should be 5. - return engine.getDisplayValue(); - } - - public static void main(String[] args) { - CalcEngineTester tester = new CalcEngineTester(); - tester.testAll(); - } -} diff --git a/src/test/java/fr/nancy/iut/CalcEngineTest.java b/src/test/java/fr/nancy/iut/CalcEngineTest.java index 91a1e4e3123eed40a4d01a8aca97ac977c0ce724..f9138b61bedf9454a5e74b5df5f24c0af00ff144 100644 --- a/src/test/java/fr/nancy/iut/CalcEngineTest.java +++ b/src/test/java/fr/nancy/iut/CalcEngineTest.java @@ -1,50 +1,41 @@ package fr.nancy.iut; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -public class CalcEngineTest { - @Test - void testClear() { - - } - - @Test - void testEquals() { - - } - - @Test - void testGetAuthor() { - - } - - @Test - void testGetDisplayValue() { - - } - - @Test - void testGetTitle() { - - } +import static org.junit.jupiter.api.Assertions.assertEquals; - @Test - void testGetVersion() { +public class CalcEngineTest { - } + private final CalcEngine engine = new CalcEngine(); @Test + @DisplayName("Testing the subtraction operation : 9 - 4 = 5") void testMinus() { - - } - - @Test - void testNumberPressed() { - + // Make sure the engine is in a valid starting state. + engine.clear(); + // Simulate the presses: 9 - 4 = + engine.numberPressed(9); + engine.minus(); + engine.numberPressed(4); + engine.equals(); + // Return the result, which should be 5. + assertEquals(5, engine.getDisplayValue()); } @Test + @DisplayName("TTesting the addition operation : 3 + 4 = 7") void testPlus() { - + // Make sure the engine is in a valid starting state. + engine.clear(); + // Simulate the key presses: 3 + 4 = + engine.numberPressed(3); + engine.plus(); + engine.numberPressed(4); + engine.equals(); + // Return the result, which should be 7. + assertEquals(7, engine.getDisplayValue()); } + }