diff --git a/src/test/java/de/tum/in/test/api/ExceptionFailureTest.java b/src/test/java/de/tum/in/test/api/ExceptionFailureTest.java index a8ff9e22..26ce3875 100644 --- a/src/test/java/de/tum/in/test/api/ExceptionFailureTest.java +++ b/src/test/java/de/tum/in/test/api/ExceptionFailureTest.java @@ -11,6 +11,7 @@ import org.opentest4j.MultipleFailuresError; import de.tum.in.test.api.util.UnexpectedExceptionError; +import de.tum.in.test.testutilities.CustomConditions; import de.tum.in.test.testutilities.TestTest; import de.tum.in.test.testutilities.UserBased; import de.tum.in.test.testutilities.UserTestResults; @@ -32,6 +33,8 @@ class ExceptionFailureTest { private final String multipleFailures = "multipleFailures"; private final String nullPointer = "nullPointer"; private final String softAssertion = "softAssertion"; + private final String throwExceptionInInitializerError = "throwExceptionInInitializerError"; + private final String throwNullPointerException = "throwNullPointerException"; @TestTest void test_assertionFailed() { @@ -130,4 +133,18 @@ void test_softAssertion() { && m.contains("1) A") // && m.contains("2) B"))))); } + + @TestTest + void test_throwExceptionInInitializerError() { + tests.assertThatEvents().haveExactly(1, CustomConditions.testFailedWith(throwExceptionInInitializerError, + ExceptionInInitializerError.class, + "abc\n" + "/// potential problem location: de.tum.in.testuser.subject.ExceptionFailurePenguin.throwExceptionInInitializerError(ExceptionFailurePenguin.java:14) ///")); + } + + @TestTest + void test_throwNullPointerException() { + tests.assertThatEvents().haveExactly(1, CustomConditions.testFailedWith(throwNullPointerException, + NullPointerException.class, + "xyz\n" + "/// potential problem location: de.tum.in.testuser.subject.ExceptionFailurePenguin.throwNullPointerException(ExceptionFailurePenguin.java:10) ///")); + } } diff --git a/src/test/java/de/tum/in/testuser/ExceptionFailureUser.java b/src/test/java/de/tum/in/testuser/ExceptionFailureUser.java index 941b8f47..d7a581ff 100644 --- a/src/test/java/de/tum/in/testuser/ExceptionFailureUser.java +++ b/src/test/java/de/tum/in/testuser/ExceptionFailureUser.java @@ -18,11 +18,13 @@ import de.tum.in.test.api.PathType; import de.tum.in.test.api.WhitelistPath; import de.tum.in.test.api.jupiter.PublicTest; +import de.tum.in.test.api.localization.UseLocale; import de.tum.in.testuser.subject.CustomException; +import de.tum.in.testuser.subject.ExceptionFailurePenguin; @AllowThreads(maxActiveCount = 100) @TestMethodOrder(MethodName.class) -//@UseLocale("en") +@UseLocale("en") @WhitelistPath(value = "target/**", type = PathType.GLOB) @BlacklistPath(value = "**Test.{java,class}", type = PathType.GLOB) @SuppressWarnings("static-method") @@ -121,4 +123,14 @@ void nullPointer() { void softAssertion() { throw new SoftAssertionError(List.of("A", "B")); } + + @PublicTest + void throwExceptionInInitializerError() { + ExceptionFailurePenguin.throwExceptionInInitializerError(); + } + + @PublicTest + void throwNullPointerException() { + ExceptionFailurePenguin.throwNullPointerException(); + } } diff --git a/src/test/java/de/tum/in/testuser/subject/ExceptionFailurePenguin.java b/src/test/java/de/tum/in/testuser/subject/ExceptionFailurePenguin.java new file mode 100644 index 00000000..5802cd8a --- /dev/null +++ b/src/test/java/de/tum/in/testuser/subject/ExceptionFailurePenguin.java @@ -0,0 +1,16 @@ +package de.tum.in.testuser.subject; + +public final class ExceptionFailurePenguin { + + private ExceptionFailurePenguin() { + + } + + public static void throwNullPointerException() { + throw new NullPointerException("xyz"); + } + + public static void throwExceptionInInitializerError() { + throw new ExceptionInInitializerError("abc"); + } +}