Skip to content

Commit

Permalink
JUnit: Upgrade to JUnit 5.4.0
Browse files Browse the repository at this point in the history
We write our tests using the JUnit 5.1.0 API. The JUnit 5.1.0 API
contains most features we require, such as assertTrue or assertThrows.

We have unit tests such as StorageManagerTest#prefsReadSave that
require writing to the filesystem. These tests need to make use of
temporary directories. This is so that
(1) we can begin with a clean, known state at the start of each test
and
(2) we can prevent our test output from polluting the user's file
system.

However, JUnit 5.1.0 does not support creating temporary directories
natively, so developers need to create a custom TemporaryDirectory
implementation or rely on JUnit-Pioneer library [1]. Both of these
solutions make it complicated to implement and for future developers
to understand.

JUnit 5.4.0 is the first version of JUnit that has a native temporary
directory API [2]. By upgrading to JUnit 5.4.0, we can directly use
the org.junit.jupiter.api.io.TempDir API.
This reduces the complexity of implementing a temporary directory.

Let's upgrade to use JUnit 5.4.0.

[1] https://medium.com/@GalletVictor/migration-from-junit-4-to-junit-5-d8fe38644abe
[2] junit-team/junit5#1247
  • Loading branch information
sijie123 committed Apr 13, 2019
1 parent 8ba95a8 commit 42a95f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Expand Up @@ -43,7 +43,7 @@ test {

dependencies {
String testFxVersion = '4.0.15-alpha'
String jUnitVersion = '5.1.0'
String jUnitVersion = '5.4.0'

implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.0'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.7.4'
Expand Down

0 comments on commit 42a95f3

Please sign in to comment.