Let's weight up a couple of testing approaches. We will test these two simple functions:
sum(List<Integer>) : int
max(List<Integer>) : int
The simplest way to cover this functionality with tests will be to use assertEquals
and assertTrue
members of the org.junit.jupiter.api.Assertions
class, so we write tests like these:
public class FunctionsTest {
@Test void testIfListIsEmptyForSum() {
assertEquals(0, sum(emptyList()));