Skip to content

Commit

Permalink
Tests should (optionally) fail if container env not available
Browse files Browse the repository at this point in the history
Add exception override support
  • Loading branch information
jasondlee committed Nov 18, 2024
1 parent a4c67c5 commit 5dbbedf
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Throwable>) override;
}
}
throw createException(throwable);
}
}
final TestcontainerRegistry instances = new TestcontainerRegistry();
Expand Down

0 comments on commit 5dbbedf

Please sign in to comment.