File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ repositories {
12
12
dependencies {
13
13
testImplementation platform(' org.junit:junit-bom:5.9.1' )
14
14
testImplementation(' org.junit.jupiter:junit-jupiter' )
15
+ testImplementation (' org.junit.jupiter:junit-jupiter:5.10.0' )
15
16
}
16
17
17
18
test {
Original file line number Diff line number Diff line change
1
+ public class Calculator {
2
+ int add (int a , int b ){
3
+ return a + b ;
4
+ }
5
+ int subtract (int a , int b ){
6
+ return a - b ;
7
+ }
8
+ int multiply (int a , int b ){
9
+ return a * b ;
10
+ }
11
+ int divide (int a , int b ){
12
+ return a / b ;
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ import org .junit .jupiter .api .Test ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+
5
+ public class CalculatorTest {
6
+ Calculator c = new Calculator ();
7
+
8
+ @ Test
9
+ void testAdd (){
10
+ int result = c .add (2 ,3 );
11
+ assertEquals (5 ,result );
12
+ }
13
+ @ Test
14
+ void testSubtract (){
15
+ int result = c .subtract (2 ,3 );
16
+ assertEquals (-1 ,result );
17
+ }
18
+
19
+ @ Test
20
+ void testMultiply (){
21
+ int result = c .multiply (2 ,3 );
22
+ assertEquals (6 ,result );
23
+ }
24
+ @ Test
25
+ void testDivide (){
26
+ int result = c .divide (6 ,3 );
27
+ assertEquals (2 ,result );
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments