Tests: Test-Reihenfolge definiert, da das Topic nicht geleert wird
authorKai Moritz <kai@juplo.de>
Sun, 10 Apr 2022 14:02:07 +0000 (16:02 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 11 Apr 2022 13:23:50 +0000 (15:23 +0200)
src/test/java/de/juplo/kafka/ApplicationTests.java

index 21d1668..5e439d6 100644 (file)
@@ -11,7 +11,10 @@ import org.apache.kafka.common.serialization.BytesSerializer;
 import org.apache.kafka.common.serialization.LongSerializer;
 import org.apache.kafka.common.serialization.StringSerializer;
 import org.apache.kafka.common.utils.Bytes;
+import org.junit.jupiter.api.MethodOrderer;
+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.ConfigDataApplicationContextInitializer;
 import org.springframework.boot.test.context.TestConfiguration;
@@ -35,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 
 @SpringJUnitConfig(initializers = ConfigDataApplicationContextInitializer.class)
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 @TestPropertySource(
                properties = {
                                "consumer.bootstrap-server=${spring.embedded.kafka.brokers}",
@@ -61,6 +65,7 @@ class ApplicationTests
 
 
        @Test
+       @Order(1) // << The poistion pill is not skipped. Hence, this test must run first
        void commitsCurrentOffsetsOnSuccess()
        {
                send100Messages(i ->  new Bytes(longSerializer.serialize(TOPIC, i)));
@@ -77,6 +82,7 @@ class ApplicationTests
        }
 
        @Test
+       @Order(2)
        void commitsNoOffsetsOnError()
        {
                send100Messages(counter ->