Grokking Java Interview Questions
0% completed
Unit Testing With JUnit and Mockito
Two test methods call the same faulty code. The method total() of a cart forgets to multiply by the quantity, so three apples at 120 cents cost 120 and not 360. The first test prints the total, and it passes. The second test compares the total with 360, and it fails with this message:
org.opentest4j.AssertionFailedError: expected: <360> but was: <120>
The difference is one line. A test without a comparison leaves the decision to the person who reads the output, and the test tool cannot see the error
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%