Closed mureinik closed 9 months ago
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.
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:
junit:junit:4.13.2
dependency was replaced withorg.junit.jupiter:junit-jupiter:5.8.1
org.hamcrest:hamcrest:2.2
was addedAnnotations
org.junit.jupiter.api.BeforeEach
was used as a drop-in replacement fororg.junit.Before
org.junit.jupiter.api.Test
was used as a drop-in replacement fororg.junit.Test
without arguments. See "Assertions" below for handling oforg.junit.Test
with an "expected" argumentAssertions
org.junit.jupiter.api.Assertions
was used as a drop-in replacement fororg.junit.Assert
in 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#assertThat
was used as a drop-in replacement fororg.junit.Assert#assertThat
org.junit.jupiter.api.Assertions#assertThrows
was used to assert cases where a method call should throw an exception instead of passing an "expected" argument to the@Test
annotation. 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
org.junit.rules.TemporaryFolder
were 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.