March 2018
Intermediate to advanced
208 pages
4h 52m
English
| | class OxygenTankTest { |
| | static final double PERMILLE = 0.001; |
| | |
| | @Test |
| » | @Disabled |
| | void testFill() { |
| | OxygenTank smallTank = OxygenTank.withCapacity(50); |
| | |
| | smallTank.fill(22); |
| | |
| | Assertions.assertEquals(0.44, smallTank.getStatus(), PERMILLE); |
| | } |
| | |
| » | @Test |
| | private void testFill2() { |
| | OxygenTank bigTank = OxygenTank.withCapacity(10_000); |
| | bigTank.fill(5344.0); |
| | |
| | Executable when = () -> bigTank.fill(6000); |
| | |
| | Assertions.assertThrows(IllegalArgumentException.class, when); |
| | } |
| | } |
Eventually, tests will fail. That’s what they’re there for—telling you when you break something. When tests fail, the first thing you’ll see is their name. Good names are valuable—they help you find the cause for failure faster. ...