Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calculator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIERRON Laurent
calculator
Commits
2c10fd55
Commit
2c10fd55
authored
2 years ago
by
PIERRON Laurent
Browse files
Options
Downloads
Patches
Plain Diff
Moving tests in Junit5 CalcEngineTest.java
parent
8d3a9264
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/fr/nancy/iut/CalcEngineTester.java
+0
-74
0 additions, 74 deletions
src/main/java/fr/nancy/iut/CalcEngineTester.java
src/test/java/fr/nancy/iut/CalcEngineTest.java
+26
-35
26 additions, 35 deletions
src/test/java/fr/nancy/iut/CalcEngineTest.java
with
26 additions
and
109 deletions
src/main/java/fr/nancy/iut/CalcEngineTester.java
deleted
100755 → 0
+
0
−
74
View file @
8d3a9264
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
();
}
}
This diff is collapsed.
Click to expand it.
src/test/java/fr/nancy/iut/CalcEngineTest.java
+
26
−
35
View file @
2c10fd55
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
());
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment