Part 10 / Topic 1 of 12
Why automated tests?
Every program so far has been checked the same way: run it, read the output, decide by eye whether it looks right. That works for a ten-line program. It stops working the moment a program has more than one method that can break, because "look right" does not scale and does not repeat itself the same way twice.
Real-world example: DiscountCalculator.finalPrice(1000.0, 20.0) from Stage 1 Part 5. A manual check means running it, reading 944.0, and deciding in your head that 1000 - 20% = 800, 800 + 18% GST = 944, so the output is correct — every single time you touch that method, for the rest of the project.
Manual check: run it -> read the number -> do the maths in your head -> decide
Automated test: run it -> the expected number is already written down -> pass/fail, instantly
An automated test is the same check, except the "what should this be?" step is written down once, in code, so it runs itself — in milliseconds, the same way every time, and it still remembers to run after you have forgotten what finalPrice even does. The rest of this part is about writing that written-down check with JUnit 5, and writing it so it is still worth reading six months later.
Done here? The practice set for Part 10 — including the solutions — is on the part page.