diff --git a/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java index b78694cf5..12455fe13 100644 --- a/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/MySqlIntegrationTests.java @@ -37,7 +37,7 @@ import org.testcontainers.junit.jupiter.Testcontainers; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("mysql") -@Testcontainers +@Testcontainers(disabledWithoutDocker = true) class MySqlIntegrationTests { @ServiceConnection diff --git a/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java index 5053e7ada..4adb92e50 100644 --- a/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java @@ -17,6 +17,7 @@ package org.springframework.samples.petclinic; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.Arrays; import java.util.LinkedList; @@ -24,6 +25,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -42,6 +44,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.samples.petclinic.vet.VetRepository; import org.springframework.test.context.ActiveProfiles; import org.springframework.web.client.RestTemplate; +import org.testcontainers.DockerClientFactory; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "spring.docker.compose.skip.in-tests=false", // "spring.docker.compose.profiles.active=postgres" }) @@ -57,6 +60,11 @@ public class PostgresIntegrationTests { @Autowired private RestTemplateBuilder builder; + @BeforeAll + static void available() { + assumeTrue(DockerClientFactory.instance().isDockerAvailable(), "Docker not available"); + } + public static void main(String[] args) { new SpringApplicationBuilder(PetClinicApplication.class) // .profiles("postgres") //