From: Kai Moritz Date: Mon, 18 Apr 2022 10:41:47 +0000 (+0200) Subject: Tests: Refaktorisiert - Durcheinander bei Assertions aufgeräumt X-Git-Tag: wip-DEPRECATED~11^2^2~4 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ac56a4e914c4a7d687c8c85b2608f0e397372d56;p=demos%2Fkafka%2Ftraining Tests: Refaktorisiert - Durcheinander bei Assertions aufgeräumt * Zuvor wurden die Assertions von JUnit Jupiter und AssertJ durcheinander gewürfelt verwendet. * Jetzt werden stringent nur noch die Assertions von AssertJ verwendet. --- diff --git a/src/test/java/de/juplo/kafka/ApplicationTests.java b/src/test/java/de/juplo/kafka/ApplicationTests.java index 92074ff..40dc149 100644 --- a/src/test/java/de/juplo/kafka/ApplicationTests.java +++ b/src/test/java/de/juplo/kafka/ApplicationTests.java @@ -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);