0
我試着寫一個異常類,這裏是我的代碼:爲什麼JUnit調用「object」而不是「exception」?
public class DealWithMeException {
public DealWithMeException(String message){
message="To make a class a checked exception it needs be a subclass of the appropriate Java class";
}
}
當我運行我的JUnit測試,錯誤總是出現並說「呼叫Java.long.object代替Java.long .exceptions」
,這裏是我的JUnit測試代碼:
public class ExceptionsTest {
@Test
public final void testCheckedException() {
Class<DealWithMeException> cut = DealWithMeException.class;
assertEquals("To make a class a checked exception it needs be a subclass of the appropriate Java class",
Exception.class, cut.getSuperclass());
}
}
發生了什麼?
非常感謝! – Yang