Tests: Refaktorisiert - Durcheinander bei Assertions aufgeräumt
authorKai Moritz <kai@juplo.de>
Mon, 18 Apr 2022 10:41:47 +0000 (12:41 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 18 Apr 2022 10:41:50 +0000 (12:41 +0200)
* Zuvor wurden die Assertions von JUnit Jupiter und AssertJ durcheinander
  gewürfelt verwendet.
* Jetzt werden stringent nur noch die Assertions von AssertJ verwendet.

src/test/java/de/juplo/kafka/ApplicationTests.java

index 92074ff..40dc149 100644 (file)
@@ -31,10 +31,8 @@ import java.util.stream.IntStream;
 
 import static de.juplo.kafka.ApplicationTests.PARTITIONS;
 import static de.juplo.kafka.ApplicationTests.TOPIC;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.*;
 import static org.awaitility.Awaitility.*;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 @SpringJUnitConfig(initializers = ConfigDataApplicationContextInitializer.class)
@@ -93,10 +91,9 @@ class ApplicationTests
                                        compareToCommitedOffsets(newOffsets);
                                });
 
-               assertThrows(
-                               IllegalStateException.class,
-                               () -> endlessConsumer.exitStatus(),
-                               "Consumer should still be running");
+               assertThatExceptionOfType(IllegalStateException.class)
+                               .isThrownBy(() -> endlessConsumer.exitStatus())
+                               .describedAs("Consumer should still be running");
        }
 
        @Test
@@ -126,9 +123,9 @@ class ApplicationTests
                                .describedAs("Received not all sent events")
                                .isLessThan(100);
 
-               assertDoesNotThrow(
-                               () -> endlessConsumer.exitStatus(),
-                               "Consumer should not be running");
+               assertThatNoException()
+                               .describedAs("Consumer should not be running")
+                               .isThrownBy(() -> endlessConsumer.exitStatus());
                assertThat(endlessConsumer.exitStatus())
                                .describedAs("Consumer should have exited abnormally")
                                .containsInstanceOf(RecordDeserializationException.class);