JUnit 5 utilities for conditional execution of Docker/Podman-based tests.
This module provides a @RequiresDocker annotation that conditionally executes tests based on Docker or Podman availability and user preferences. It automatically checks for both Docker and Podman container engines.
Add the dependency to your test module:
<dependency>
<groupId>org.a2aproject.sdk</groupId>
<artifactId>a2a-java-test-utils-docker</artifactId>
<scope>test</scope>
</dependency>Annotate test classes that require Docker:
import io.a2a.testutils.docker.RequiresDocker;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
@QuarkusTest
@RequiresDocker
public class MyDockerBasedTest {
@Test
public void testSomethingWithDocker() {
// Test that requires Docker (e.g., Testcontainers, Quarkus Dev Services)
}
}-DskipDockerTests |
Docker/Podman Available | Behavior |
|---|---|---|
| Not set | ✅ Yes | RUN tests normally |
| Not set | ❌ No | ABORT tests with error message |
true |
✅ Yes | SKIP tests (shown as disabled) |
true |
❌ No | SKIP tests (shown as disabled) |
mvn clean installmvn clean install -DskipDockerTests=trueWithout skip flag:
mvn clean install
# Tests ABORT with: "Docker/Podman is not available. Use -DskipDockerTests=true to skip these tests."With skip flag:
mvn clean install -DskipDockerTests=true
# Tests are SKIPPED, build succeeds
# Modules still compile- Container Detection: Checks for both
dockerandpodmancommands by executingdocker infoorpodman info - JUnit 5 Extension: Implements
ExecutionConditionto control test execution - Class-Level Only: Annotation is applied at the class level (not method level)
- Compilation: Modules are always compiled regardless of Docker/Podman availability or skip flag
- No External Dependencies: Uses only Java standard library for container detection (no Testcontainers dependency)
This is useful for:
- CI/CD pipelines where Docker/Podman may not be available
- Local development when container daemon is not running
- Quarkus Dev Services tests that automatically start containers
- Testcontainers-based integration tests
- Podman users who use Podman instead of Docker