diff --git a/exercises/concept/cars-assemble/src/test/java/CarsAssembleTest.java b/exercises/concept/cars-assemble/src/test/java/CarsAssembleTest.java index 8cdf0ee9c..4a032d60b 100644 --- a/exercises/concept/cars-assemble/src/test/java/CarsAssembleTest.java +++ b/exercises/concept/cars-assemble/src/test/java/CarsAssembleTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.within; public class CarsAssembleTest { @@ -20,42 +21,42 @@ public void setUp() { @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 0") public void productionRatePerHourForSpeedZero() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(0) - 0.0) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(0)).isCloseTo(0.0, within(epsilon)); } @Test @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 1") public void productionRatePerHourForSpeedOne() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(1) - 221.0) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(1)).isCloseTo(221.0, within(epsilon)); } @Test @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 4") public void productionRatePerHourForSpeedFour() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(4) - 884.0) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(4)).isCloseTo(884.0, within(epsilon)); } @Test @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 7") public void productionRatePerHourForSpeedSeven() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(7) - 1392.3) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(7)).isCloseTo(1392.3, within(epsilon)); } @Test @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 9") public void productionRatePerHourForSpeedNine() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(9) - 1591.2) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(9)).isCloseTo(1591.2, within(epsilon)); } @Test @Tag("task:1") @DisplayName("The productionRatePerHour method returns the correct result when line's speed is 10") public void productionRatePerHourForSpeedTen() { - assertThat(Math.abs(carsAssemble.productionRatePerHour(10) - 1701.7) < epsilon).isTrue(); + assertThat(carsAssemble.productionRatePerHour(10)).isCloseTo(1701.7, within(epsilon)); } @Test