From 3d790aeddeb65691a3680c2f473cdff7d7b3a553 Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 20:32:24 +0100 Subject: [PATCH 1/2] changes in the class --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index bf170fe..2768e73 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -10,19 +10,7 @@ class UsbPlayerTest { UsbPlayer up = new UsbPlayer(); - @Test - void louder_test() { - up.setLautstaerke(40); - up.louder(); - assertThat(up.getLautstaerke()).isEqualTo(41); - } - @Test - void quieter_test() { - up.setLautstaerke(40); - up.quieter(); - assertThat(up.getLautstaerke()).isEqualTo(39); - } /* @Test void getVolume() { From 0d4825e2d1961bb8ce71cef89a07d5ad259b3343 Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 20:43:27 +0100 Subject: [PATCH 2/2] QuieterTest is implemented --- .../java/device/usbPlayer/UsbPlayerTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 2768e73..b0dcdc7 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -1,6 +1,11 @@ package device.usbPlayer; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; @@ -9,7 +14,24 @@ class UsbPlayerTest { UsbPlayer up = new UsbPlayer(); + @ParameterizedTest + @MethodSource("quieterOptions") + void quieterTest(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); + } + static Stream quieterOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.quieter(); + UsbPlayer up2 = new UsbPlayer(); + up2.setLautstaerke(10); + up2.quieter(); + return Stream.of( + Arguments.of("Volume must stay 0 ", up1, 0), + Arguments.of("Volume must be 9 ", up2, 9) + ); + } /* @Test