Browse Source

Method getInfoText of CDPlayer tested on ExceptionShouldReturnAMessage.

feature-pr-RadioPlayer-getOptions
JPANZO 3 years ago
parent
commit
d606a41ef7
  1. 10
      src/test/java/device/cdPlayer/CDPlayerTest.java

10
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){
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<Arguments> 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.")
);
}
Loading…
Cancel
Save