March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class CruiseControlTest { |
| | |
| | @Test |
| | void setPlanetarySpeedIs7667() { |
| | CruiseControl cruiseControl = new CruiseControl(); |
| | |
| | cruiseControl.setPreset(SpeedPreset.PLANETARY_SPEED); |
| | |
| » | Assertions.assertEquals(cruiseControl.getTargetSpeedKmh(), 7667); |
| | } |
| | } |
The test above looks correct, doesn’t it? You can see its structuring into different parts, it uses assertEquals() to compare the results, and it has a meaningful name. You need to look closely to find a problem in the code.
It gets more obvious when you run the test and the assertion fails. If that happens, you’ll get a message like this one:
expected: <1337> but was <7667>
The message tells you that the two values in the assertEquals() method are different. ...