Skip to content

Replace junit-dataprovider with junit-jupiter-params#1655

Merged
hankem merged 11 commits into
mainfrom
replace-junit-dataprovider
Jul 10, 2026
Merged

Replace junit-dataprovider with junit-jupiter-params#1655
hankem merged 11 commits into
mainfrom
replace-junit-dataprovider

Conversation

@hankem

@hankem hankem commented Jul 6, 2026

Copy link
Copy Markdown
Member

Resolves #1471

Comment thread archunit/src/test/java/com/tngtech/archunit/core/importer/ImportOptionsTest.java Outdated
@Rule
public final ArchConfigurationRule configurationRule = new ArchConfigurationRule();
@RegisterExtension
ArchConfigurationExtension archConfiguration = new ArchConfigurationExtension();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: include in the commit message the migration ArchConfigurationRule -> ArchConfigurationExtension
I know that it must be done because of junit4 ->junit5 but I think it wouldn't hurt to make it explicit

you even created that Extension in this commit! 🙂
I think that's worth a mention

import org.junit.rules.ExternalResource;

/**
* @deprecated use JUnit 5 and {@link ArchConfigurationExtension} instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it feasible to entirely remove this Rule?
I might give it a try later, there seem to be only 25 tests left

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is certainly possible.
It would just be unrelated to the goal Replace junit-dataprovider with junit-jupiter-params.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we'll do it in another PR.
maybe one to get rid of junit4 for the tests for archunit entirely. let's see when we have how much time.
There haven't been any Techdays for me for some time

@@ -56,7 +56,7 @@ public void locations_of_packages_within_JAR_URIs() throws Exception {
Set<Location> locations = Locations.ofPackage("org.junit");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you replace this string by org.junit.jupiter.api you can replace org.junit.Test.class by Test.class
I see no reason to use the junit4 variant of it.
let's break that dependency (there are 3 more usages in this class of the class literal)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want the commit migrate ClassFileImporterTest to junit-jupiter-params to change any test logic.
Changing org.junit.Test to org.junit.jupiter.api.Test would perfectly fit in a PR whose goal is to get rid of JUnit 4, but is irrelevant for the goal to eliminate the junit-dataprovider.

@StefanGraeber StefanGraeber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but you lost a commit gin-off ;)
also don't forget to squash the fixup commits

hankem and others added 11 commits July 10, 2026 18:20
…nit-dataprovider dependency

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
…Value}Source

Note that
> By default, `@CsvSource` uses a single quote (') as its quote character [...]
> An empty, quoted value ('') results in an empty String [...]
> whereas an entirely empty value is interpreted as a null reference.
[https://junit.org/junit5/docs/current/api/org.junit.jupiter.params/org/junit/jupiter/params/provider/CsvSource.html]

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
Signed-off-by: Stefan Gräber <stefan.graeber@tngtech.com>

Co-authored-by: Manfred Hanke <manfred.hanke@tngtech.com>
Signed-off-by: Manfred Hanke <manfred.hanke@tngtech.com>
…dSource

For convenience (and to keep the diff smaller)
`com.tngtech.archunit.testutil.DataProviders.$` provides the same API for `junit-jupiter-params`
as `com.tngtech.java.junit.dataprovider.DataProviders.$` did for `junit-dataprovider`.

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
…it-jupiter-params

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
…unit-jupiter-params

introducing `ArchConfigurationExtension`

Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
replacing the JUnit 4 `@Rule`s with JUnit Jupiter extensions
(`ContextClassLoaderExtension`, `LogTestExtension`, `OutsideOfClassPathExtension`, `ReplaceFileExtension`, `SystemPropertiesExtension`)
and also converting some other tests that made use of the same `TestRule`s to JUnit 5
to eliminate some of these custom `TestRule`s already
(`LogTestRule`, `OutsideOfClassPathRule`, `ReplaceFileRule`)

Signed-off-by: Manfred Hanke <manfred.hanke@tngtech.com>
Signed-off-by: Manfred Hanke <manfred.hanke@tngtech.com>
…piter-params

Signed-off-by: Manfred Hanke <manfred.hanke@tngtech.com>
Signed-off-by: Manfred Hanke <Manfred.Hanke@tngtech.com>
Signed-off-by: Stefan Gräber <stefan.graeber@tngtech.com>
@hankem hankem force-pushed the replace-junit-dataprovider branch from c4c9eb3 to ca4035c Compare July 10, 2026 16:26
@hankem hankem merged commit 889ce73 into main Jul 10, 2026
31 of 32 checks passed
@hankem hankem deleted the replace-junit-dataprovider branch July 10, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants