Skip to content

Commit

Permalink
Add JUnit counterpart to AssertJ example
Browse files Browse the repository at this point in the history
  • Loading branch information
kasramp committed Apr 7, 2024
1 parent 6ec0317 commit 17871cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions assertj/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
<version>3.25.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.10.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -29,4 +30,9 @@ void shouldThrowUserNotFoundException() {
.isInstanceOf(UserNotFoundException.class)
.hasMessage("Cannot find username: nonExistenceUsername");
}

@Test
void shouldVerifyUserNotFoundExceptionIsThrown() {
assertThrows(UserNotFoundException.class, () -> userRepository.findByUsername("nonExistenceUsername"));
}
}

0 comments on commit 17871cd

Please sign in to comment.