arquillian / arquillian-testcontainers

Arquillian loadable extension for test-container support
Apache License 2.0
5 stars 4 forks source link

Tests should (optionally) fail if container env not available #41

Open jasondlee opened 5 hours ago

jasondlee commented 5 hours ago

There are times when a test should be skipped if Docker is not available, while at other times the test should fail. For example, one might want the containerized test to run on Mac or Linux, but not on Windows. This behavior should be easily configured. For example, in the WildFly codebase (from which these annotations were taken), a system property is examined to determine whether to skip or fail. This project needs this sort of flexibility.

For example

if (!isDockerAvailable()) {
    if ("true".equals(System.getProperty("arquillian.testcontainers.require.docker"))) {
        throw new RuntimeException("Docker is required but it is not available or is not properly configured");
    } else {
        throw createException(dockerRequired.value());
    }
}
jamezp commented 4 hours ago

Another option might be to have a system property like org.arquillian.testcontainers.required.exception=java.lang.AssertionError and allow the type to be overridden.