KittehIRCClientLib
KittehIRCClientLib copied to clipboard
Migrate tests to modern JUnit Jupiter
The project currently uses the outdated JUnit 4.13.2. In order to make it easier to write tests and easier for future contributors to easily start working with the project, this patch migrates the test suite to the modern JUnit Jupiter.
This patch contains the following changes:
-
Dependencies:
- The
junit:junit:4.13.2dependency was replaced withorg.junit.jupiter:junit-jupiter:5.8.1 - Unlike JUnit 4, JUnit Jupiter does not bundle the hamcrest library, so the explicit dependency
org.hamcrest:hamcrest:2.2was added
- The
-
Annotations
org.junit.jupiter.api.BeforeEachwas used as a drop-in replacement fororg.junit.Beforeorg.junit.jupiter.api.Testwas used as a drop-in replacement fororg.junit.Testwithout arguments. See "Assertions" below for handling oforg.junit.Testwith an "expected" argument
-
Assertions
org.junit.jupiter.api.Assertionswas used as a drop-in replacement fororg.junit.Assertin the cases the "message" argument was not used. In the cases a "message" argument was used it was moved to be the last argument instead of the first argumentorg.hamcrest.MatcherAssert#assertThatwas used as a drop-in replacement fororg.junit.Assert#assertThatorg.junit.jupiter.api.Assertions#assertThrowswas used to assert cases where a method call should throw an exception instead of passing an "expected" argument to the@Testannotation. As a side bonus, this also makes the tests stricter, as it asserts the actual method call threw the expected exception and not the code used to set up its arguments/environment.
-
Misc
- Tests using
org.junit.rules.TemporaryFolderwere rewritten to use the similarorg.junit.jupiter.api.io.TempDir. While these two classes conceptually have the same functionality their APIs are different, and this is not a drop-in replacement.
- Tests using
This seems reasonable to me! I just might take a bit to get around to reviewing so I'm throwing up the accepted label in celebration of hacktoberfest in the mean time :)
Much appreciated!
I'm fully aware it's finiky to review, but I couldn't think of a reasonable way to make this PR any smaller - at least not without doing half a job, and leaving the project in a half JUnit 4 half JUnit Jupiter mess.