0
何らかの理由で、私は正しく私の検証でのコーディングにもかかわらず、JUnitの4は、例外がスローされた場合でも、失敗を上げ続ける:JUnit 4はスローされた例外を受け取りません
コード:
try {
if (firstname == null) {
throw new IllegalArgumentException("First name cannot be null");
}catch (IllegalArgumentException e) {
e.getMessage();
e.printStackTrace();
}
のJUnit:
@Test(expected=IllegalArgumentException.class)
public void testUserInvalidConstructions() {
User user = new User(null);
}
しかし、あなたはそれを投げた直後に例外をキャッチしました。 –
@Törpetestűoooh –