Demo: turning copy-pasted tests into a parameterized table
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
refactor repeated tests into one table. Prepares JNR-043-LAB1.
Draft outline details
Step by step
- Show ten near-identical tests for Shop discount and tax rules.
- Create one
@ParameterizedTestwith@CsvSource; move the data into rows. - Add a readable
nametemplate and run; each row reports separately. - Add edge rows (zero, maximum discount, rounding).
- Planned mistake: compare
BigDecimalwithassertEqualsand100.0vs100.00fails; fix withisEqualByComparingTo. - Plant a bug in the calculator and show a row failing.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.