Sep 8, 2024
SimpleCalculator
add(int a, int b)
that returns the sum of two integers.Ctrl + Shift + T
to create a test for a class.SimpleCalculatorTest
).source/test/java
in the project structure.@Test
annotation (import from org.junit.jupiter.api
).2 + 2
equals 4
.assertEquals(expected, actual)
to verify results.assertEquals(4, calculator.add(2, 2));
assertEquals(4, calculator.add(2, 2))
will still pass.determineLetterGrade(int grade)
which returns letter grades based on numeric grades.59 should return F
, 80 should return B
).assertThrows
to verify exceptions are thrown correctly.
IllegalArgumentException
.