Testing Tools
P19 beginner
Unit testing a Calculator with JUnit 4
Put JUnit 4 on the build path, run a real test class in Eclipse, watch the red bar on a wrong expectation, complete the division tests (delta comparison and expected exceptions) and add a parameterised test.
What you'll do
- Configure JUnit 4 in an Eclipse project
- Write assertions with assertEquals, delta and assertThrows
- Read the JUnit view: runs, failures, errors and the failure trace
- Write a parameterised test
Lab tasks
- 1 Add the JUnit 4 library
- 2 Run CalculatorTest as a JUnit test
- 3 See a failure on purpose
- 4 Write the four division tests
- 5 Add a parameterised test