assertThatNoException().isThrownBy(() -> adder.endSum("foo"));
}
+ @Test
+ @DisplayName("An existing sum is removed, if ended")
+ public void testEndSumRemovesSumIfSumExists()
+ {
+ AdderBusinessLogic adder = new AdderBusinessLogic();
+ adder.startSum("foo");
+ adder.endSum("foo");
+ assertThat(adder.getSum("foo")).isEmpty();
+ }
+
@Test
@DisplayName("An existing Sum returns a non-null value, if ended")
public void testEndSumReturnsNonNullValueIfSumExists()
assertThatIllegalArgumentException().isThrownBy(() -> adder.addToSum("foo", value));
}
- @Test
+ @ParameterizedTest(name = "{index}: Adding {0}")
@DisplayName("Can add a positive value to an existing sum")
- public void testAddSumWithPositiveValuePossibleIfSumExists()
+ @ValueSource(ints = { 1, 3, 6, 66, 7, 9 })
+ public void testAddSumWithPositiveValuePossibleIfSumExists(int value)
{
AdderBusinessLogic adder = new AdderBusinessLogic();
adder.startSum("foo");
- assertThatIllegalArgumentException().isThrownBy(() -> adder.addToSum("foo", -1));
+ assertThatNoException().isThrownBy(() -> adder.addToSum("foo", value));
}
@ParameterizedTest(name = "{index}: Summing up {0}")