From 86b5cca88c10fce0fa5a920c5dd2d48874bc4e9c Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 20:26:29 +0100 Subject: [PATCH 1/3] LouderTest implemented --- .../java/device/usbPlayer/UsbPlayerTest.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index bf170fe..25eaef1 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -1,6 +1,12 @@ 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.ArrayList; +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; @@ -47,9 +53,23 @@ class UsbPlayerTest { @Test void chooseOption() { } +*/ +@ParameterizedTest +@MethodSource("louderOptions") +void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { + int volumeNum = inputPlay.getLautstaerke(); + assertThat(volumeNum).describedAs(testName).isEqualTo(expectedResult); +} - @Test - void play() { + static Stream louderOptions() { + UsbPlayer up1 = new UsbPlayer(); + up1.louder(); + UsbPlayer up2 = new UsbPlayer(); + up2.setLautstaerke(100); + up2.louder(); + return Stream.of( + Arguments.of("Volume is : 1 ", up1, 1), + Arguments.of("Volume is : 100 ", up2, 100) + ); } - */ } \ No newline at end of file From d84f750766499fb99ebbaabc3df13018ba38ca5b Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 20:33:22 +0100 Subject: [PATCH 2/3] changes in the class --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 25eaef1..4aa0e56 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -66,7 +66,7 @@ void louderTest(String testName, UsbPlayer inputPlay, int expectedResult) { up1.louder(); UsbPlayer up2 = new UsbPlayer(); up2.setLautstaerke(100); - up2.louder(); + up2.louder(); return Stream.of( Arguments.of("Volume is : 1 ", up1, 1), Arguments.of("Volume is : 100 ", up2, 100) From 35b7f476577e284b45160f592886732c83151997 Mon Sep 17 00:00:00 2001 From: sahar Date: Mon, 7 Feb 2022 21:40:08 +0100 Subject: [PATCH 3/3] UsbPlayerTest changes --- src/test/java/device/usbPlayer/UsbPlayerTest.java | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index 4aa0e56..f90fc54 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -16,19 +16,6 @@ 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() {