From d606a41ef7dede0142ea21ee7a1b30287c2b1b76 Mon Sep 17 00:00:00 2001 From: JPANZO Date: Wed, 16 Feb 2022 20:02:33 +0100 Subject: [PATCH] Method getInfoText of CDPlayer tested on ExceptionShouldReturnAMessage. --- src/test/java/device/cdPlayer/CDPlayerTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/test/java/device/cdPlayer/CDPlayerTest.java b/src/test/java/device/cdPlayer/CDPlayerTest.java index eee04af..4e9e7c4 100644 --- a/src/test/java/device/cdPlayer/CDPlayerTest.java +++ b/src/test/java/device/cdPlayer/CDPlayerTest.java @@ -277,16 +277,22 @@ class CDPlayerTest { @ParameterizedTest @MethodSource("getInfoTestData") - void getInfoTest(String testName, CDPlayer _cdPlayer,Exception exception , String expectedResult){ - Exception newException=assertThrows(exception.getClass(),()->_cdPlayer.getInfoText()); - assertEquals(ReturnValueNullException.class, newException.getClass()); + void getInfoTest(String testName,String cases, CDPlayer _cdPlayer,Exception exception , String expectedResult){ + Exception newException = assertThrows(exception.getClass(), () -> _cdPlayer.getInfoText()); + if(cases.equals("Case1")) { + assertEquals(ReturnValueNullException.class, newException.getClass()); + } + if(cases.equals("Case2")) { + assertThat(newException.getMessage()).describedAs(testName).isEqualTo(expectedResult); + } } static Stream getInfoTestData () { CDPlayer cdPlayer1 = new CDPlayer(); return Stream.of( - Arguments.of("[getInfoText() by infoText=null ] => shouldThrowReturnValueNullException", cdPlayer1,new ReturnValueNullException(),"") + Arguments.of("[getInfoText() by infoText=null ] => shouldThrowReturnValueNullException","Case1", cdPlayer1,new ReturnValueNullException(),""), + Arguments.of("[getInfoText() by infoText=null ] => ExceptionShouldReturnAMessage","Case2",cdPlayer1,new ReturnValueNullException(),"Method should not return a Null-Value.") ); }