From 5dbbedf392cbc173eafebfdd8e2c828bf716f120 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Fri, 15 Nov 2024 11:21:22 -0600 Subject: [PATCH] Tests should (optionally) fail if container env not available Add exception override support --- .../testcontainers/TestContainersObserver.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java b/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java index dcc2517..4bf992a 100644 --- a/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java +++ b/src/main/java/org/jboss/arquillian/testcontainers/TestContainersObserver.java @@ -42,7 +42,15 @@ public void createContainer(@Observes(precedence = 500) BeforeClass beforeClass) final DockerRequired dockerRequired = javaClass.getAnnotation(DockerRequired.class); if (dockerRequired != null) { if (!isDockerAvailable()) { - throw createException(dockerRequired.value()); + var throwable = dockerRequired.value(); + final var overrideClass = System.getProperty("org.arquillian.testcontainers.docker.required.exception"); + if (overrideClass != null && !overrideClass.isBlank()) { + Class override = Class.forName(overrideClass); + if (override.isAssignableFrom(Throwable.class)) { + throwable = (Class) override; + } + } + throw createException(throwable); } } final TestcontainerRegistry instances = new TestcontainerRegistry();