From 383ebed2058e6262d55a054eef402f53f0daf59f Mon Sep 17 00:00:00 2001 From: jaguililla Date: Mon, 23 Sep 2024 22:32:46 +0200 Subject: [PATCH] Set test order to avoid problems --- .../com/github/jaguililla/appointments/ApplicationIT.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java b/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java index 7a1bf31..bed38bc 100644 --- a/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java +++ b/src/test/java/com/github/jaguililla/appointments/ApplicationIT.java @@ -11,7 +11,10 @@ import org.apache.kafka.common.TopicPartition; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; +import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.server.LocalServerPort; @@ -28,6 +31,7 @@ classes = {Application.class}, webEnvironment = RANDOM_PORT ) +@TestMethodOrder(OrderAnnotation.class) class ApplicationIT { static PostgreSQLContainer postgres = new PostgreSQLContainer<>("postgres:16-alpine"); @@ -61,6 +65,7 @@ static void configureProperties(final DynamicPropertyRegistry registry) { } @Test + @Order(1) void specification_requests_work_as_expected() { client.get("/v3/api-docs"); assertTrue(client.getResponseBody().contains("openapi")); @@ -68,6 +73,7 @@ void specification_requests_work_as_expected() { } @Test + @Order(2) void actuator_requests_work_as_expected() { client.get("/actuator/health"); assertTrue(client.getResponseBody().contains("UP")); @@ -75,6 +81,7 @@ void actuator_requests_work_as_expected() { } @Test + @Order(3) void existing_appointments_can_be_fetched() { client.get("/appointments"); var response = client.getResponseBody(AppointmentResponse[].class); @@ -84,6 +91,7 @@ void existing_appointments_can_be_fetched() { } @Test + @Order(4) void appointments_can_be_created_read_and_deleted() { client.post("/appointments", new AppointmentRequest() .id(UUID.randomUUID())