Skip to content
Snippets Groups Projects
Commit 2c10fd55 authored by PIERRON Laurent's avatar PIERRON Laurent :man_in_tuxedo_tone1:
Browse files

Moving tests in Junit5 CalcEngineTest.java

parent 8d3a9264
Branches
No related tags found
No related merge requests found
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();
}
}
package fr.nancy.iut; package fr.nancy.iut;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class CalcEngineTest { import static org.junit.jupiter.api.Assertions.assertEquals;
@Test
void testClear() {
}
@Test
void testEquals() {
}
@Test
void testGetAuthor() {
}
@Test
void testGetDisplayValue() {
}
@Test
void testGetTitle() {
}
@Test public class CalcEngineTest {
void testGetVersion() {
} private final CalcEngine engine = new CalcEngine();
@Test @Test
@DisplayName("Testing the subtraction operation : 9 - 4 = 5")
void testMinus() { void testMinus() {
// Make sure the engine is in a valid starting state.
} engine.clear();
// Simulate the presses: 9 - 4 =
@Test engine.numberPressed(9);
void testNumberPressed() { engine.minus();
engine.numberPressed(4);
engine.equals();
// Return the result, which should be 5.
assertEquals(5, engine.getDisplayValue());
} }
@Test @Test
@DisplayName("TTesting the addition operation : 3 + 4 = 7")
void testPlus() { 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());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment