mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-04-24 19:32:48 +00:00
test: refactor using AssertJ assertions
This commit is contained in:
parent
c5b3b3597e
commit
7055f0c6a6
2 changed files with 6 additions and 6 deletions
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.samples.petclinic.system;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -35,10 +36,9 @@ class CrashControllerTests {
|
|||
|
||||
@Test
|
||||
void testTriggerException() {
|
||||
RuntimeException thrown = assertThrows(RuntimeException.class, () -> testee.triggerException());
|
||||
|
||||
assertThat(thrown.getMessage())
|
||||
.isEqualTo("Expected: controller used to showcase what happens when an exception is thrown");
|
||||
assertThatExceptionOfType(RuntimeException.class)
|
||||
.isThrownBy(()->testee.triggerException())
|
||||
.withMessageContaining("Expected: controller used to showcase what happens when an exception is thrown");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue