This is an exercise about JUnit. Cart-AdditionalUnitTestTopics
folder contains a maven project. This project contains a class extending
a previous calculator (using decorator pattern) to include credits and specials discounts for different types of
users. The goal is to use more JUnit annotations like @BeforeAll
, @BeforeAll
, @RepeatedTest(n)
, @ParameterizedTest
, @MethodSource
There is some code on the TotalsWithDiscountCalculatorTest
.
Here is what we did:
-
The method
getTotalsWithDiscounts_regularAndPlatinumUser_returnsDifferentSubtotal
receives anUser
as parameter, we added the required annotations to get different types of users, and a different expected result. Tip: The methoddifferentUserTypesAndExpectedTotals
provide those. -
getTotalsWithDiscounts_userWithCredit_chargedMultipleTimes
test that a user can be charged multiple times.- We added the required annotation to initialize the
globalUser
in thesetupGlobalUser
method. - The same user can be used by different calculators, we added the required annotation to initialize them in
setupCalculator
method. - We made the
getTotalsWithDiscounts_userWithCredit_chargedMultipleTimes
method repeat three times.
- We added the required annotation to initialize the