Open
Conversation
This patch upgrades the project to use the modern JUnit Jupiter 5.9.1
instead of the outdated JUnit 4.13.1 in order to make it easier for
future contributors to write and maintain unit tests in the project.
Note:
While this patch doesn't contain any significant logic, it's already
quite large. In an attempt to keep it as easy as possible to review,
it was kept minimal and only replaces JUnit 4 constructs with JUnit
Jupiter constructs.
With JUnit Jupiter in place, some obvious improvements/cleanups are
available, but they will be performed in a followup patch.
This patch includes:
1. pom.xml
a. The junit:junit:4.13.1 dependency was replaced with the modern
org.junit.jupiter:junit-jupiter:5.9.1 dependency
b. An implicit definition of maven-surefire-plugin:2.22.2 was
introduced instead of the implicit 2.12 version that was not
specified in order to be able to execute JUnit Jupiter tests.
c. maven-dependency-plugin's excludeArtifactIds configuration was
updated to exclude junit-jupiter instead of junit
2. Annotations
a. org.junit.jupiter.api.Test was used as a drop-in replacement for
org.junit.Test in the simple case where no arguments were used
with the annotation. In the case where the expected argument was
used this annotation was still used, but the assertions in the
test had to be modified, see 3.c below
b. org.junit.jupiter.api.BeforeEach was used as a drop-in
replacement for org.junit.Before.
c. org.junit.jupiter.api.BeforeAll was used as a drop-in
replacement for org.junit.BeforeClass.
d. org.junit.jupiter.api.AfterEach was used as a drop-in
replacement for org.junit.After.
e. org.junit.jupiter.api.AfterAll was used as a drop-in
replacement for org.junit.AfterClass.
f. In the cases where multiple annotations were replaced in the same
class, imports were reorganized to keep their alphabetical order.
3. Assertions
a. org.junit.jupiter.api.Assertions' methods were used as drop-in
replacements for org.junit.Assert's methods with the same name in
the simple case where the method was used without the extra
message argument.
b. In the cases where an org.junit.Assert method was used with the
extra message argument it was replaced with a call to an
org.junit.jupiter.api.Assertions method with the same name, and
the arguments were rearranged so that the message argument would
be last instead of first.
c. org.junit.jupiter.api.Assertions' assertThrows was used to test
expected exceptions being thrown where org.junit.Test was used
with the expected argument.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR upgrades the project to use the modern JUnit Jupiter 5.9.1 instead of the outdated JUnit 4.13.1 in order to make it easier for future contributors to write and maintain unit tests in the project.
Note:
While this patch doesn't contain any significant logic, it's already quite large. In an attempt to keep it as easy as possible to review, it was kept minimal and only replaces JUnit 4 constructs with JUnit Jupiter constructs.
With JUnit Jupiter in place, some obvious improvements/cleanups are available, but they will be performed in a followup patch.
This PR includes:
junit:junit:4.13.1dependency was replaced with the modernorg.junit.jupiter:junit-jupiter:5.9.1dependencymaven-surefire-plugin:2.22.2was introduced instead of the implicit2.12version that was not specified in order to be able to execute JUnit Jupiter tests.maven-dependency-plugin'sexcludeArtifactIdsconfiguration was updated to excludejunit-jupiterinstead ofjunitorg.junit.jupiter.api.Testwas used as a drop-in replacement fororg.junit.Testin the simple case where no arguments were used with the annotation. In the case where theexpectedargument was used this annotation was still used, but the assertions in the test had to be modified, see 3.iii beloworg.junit.jupiter.api.BeforeEachwas used as a drop-in replacement fororg.junit.Before.org.junit.jupiter.api.BeforeAllwas used as a drop-in replacement fororg.junit.BeforeClass.org.junit.jupiter.api.AfterEachwas used as a drop-in replacement fororg.junit.After.org.junit.jupiter.api.AfterAllwas used as a drop-in replacement fororg.junit.AfterClass.org.junit.jupiter.api.Assertions' methods were used as drop-in replacements fororg.junit.Assert's methods with the same name in the simple case where the method was used without the extra message argument.org.junit.Assertmethod was used with the extra message argument it was replaced with a call to anorg.junit.jupiter.api.Assertionsmethod with the same name, and the arguments were rearranged so that the message argument would be last instead of first.org.junit.jupiter.api.Assertions'assertThrowswas used to test expected exceptions being thrown whereorg.junit.Testwas used with theexpectedargument.