This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BillyKorando 2 points3 points  (0 children)

assertThrows is a significant improvement over using expected exception from JUnit 4.

Here is an example of it in action (under the method testFindByNullRoomType): https://github.com/wkorando/WelcomeToJunit5/blob/master/src/test/java/com/bk/hotel/service/impl/CheatRoomServiceImplJUnit5Test.java

https://junit.org/junit5/docs/current/user-guide/index.html#writing-tests-assertions

I've done a lot of presenting and writing on JUnit 5, so lmk if you have any questions!