Skip to content
Ameen Abozaid
Planned lessonJNR-043-L06

Demo: turning copy-pasted tests into a parameterized table

  • Lesson 6 of 6
  • Junior
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

  1. Show ten near-identical tests for Shop discount and tax rules.
  2. Create one @ParameterizedTest with @CsvSource; move the data into rows.
  3. Add a readable name template and run; each row reports separately.
  4. Add edge rows (zero, maximum discount, rounding).
  5. Planned mistake: compare BigDecimal with assertEquals and 100.0 vs 100.00 fails; fix with isEqualByComparingTo.
  6. Plant a bug in the calculator and show a row failing.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.