Repository navigation
test: migrate unit tests from JUnit 4 to JUnit 6 - #6276
Merged
Merged
Conversation
JUnit 4 is in maintenance mode, and 4.13.2 (February 2021) is its last release. Move the unit tests to JUnit Jupiter 6.1.3: the JUnit BOM, junit-jupiter and the Platform launcher replace junit:junit, and the unit test tasks run on the JUnit Platform. The test sources change only mechanically: imports, lifecycle annotations, TemporaryFolder to @tempdir, and the message argument moved last in three assertions. Jupiter skips an invalid @test method, such as one that returns a value, with only a warning, where JUnit 4 failed the run. Treat discovery warnings as failures to keep that behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patterniha
added a commit
to patterniha/PattNG
that referenced
this pull request
Oct 3, 2026
Brings in 2dust/v2rayNG up to a4dd3d0 (2.3.10): the JUnit 6 test migration (2dust#6276), mockito-kotlin 6.4.0 (2dust#6273), Gradle 9.8.0 (2dust#6274), NDK r30 (2dust#6275), the navigation bar theme lint fix (2dust#6259), the main pager row overlap fix, the Luri Bakhtiari translation update (2dust#6169) and the dependency updates in libs.versions.toml. Conflicts: - build.gradle.kts: versionCode 750 and 2.3.10 as the fallback of the pattngVersion property. - values-bqi-rIR/strings.xml: upstream's translation update, with PattNG's own strings and its app_name and notification channel name kept. - ProxyChainMembersTest.kt: upstream's JUnit 6 imports, plus the ones PattNG's Aether test needs. AndroidLibXrayLite (2b1c65d, v26.10.3) and hev-socks5-tunnel (2.18.0-2-g2cdc169) stay on PattNG's pointers, which contain upstream's.
patterniha
added a commit
to patterniha/PattNG
that referenced
this pull request
Oct 3, 2026
Upstream moved v2rayNG's unit tests to JUnit 6 and dropped JUnit 4 (2dust#6276), so PattNG's 36 test files of its own no longer compiled. They change the way upstream's did: imports, @Before/@after to @BeforeEach/@AfterEach, TemporaryFolder to @tempdir, and the message moved last in the 54 assertions that have one. The two tests that used TemporaryFolder.newFolder get a newFolder helper that, like it, fails when the folder already exists.
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.
JUnit 4, which runs the app's unit tests, is in maintenance mode: only critical bugs and security issues get fixed, and 4.13.2 from February 2021 is its last release. This moves the tests to JUnit Jupiter 6.1.3; the test sources change only mechanically, and the app and its dependencies do not change.
What changes
Unit test tasks run on the JUnit Platform with the Jupiter engine.
junit:junitis replaced by the JUnit 6.1.3 BOM,junit-jupiterandjunit-platform-launcher; the launcher is declared because Gradle 9 no longer adds it by itself.The test sources get only the standard replacements:
org.junit.Test,org.junit.Assert.*org.junit.jupiter.api.Test,org.junit.jupiter.api.Assertions.*@Before,@After,@BeforeClass@BeforeEach,@AfterEach,@BeforeAll@get:Rule val temporaryFolder = TemporaryFolder()@TempDir lateinit var tempDir: FileassertFalse("message", condition)assertFalse(condition, "message"): the message goes lastWhy
junit.platform.discovery.issue.severity.critical=WARNINGJUnit 4 fails the run on an invalid
@Testmethod, such as one that returns a value. Jupiter only reports a warning and skips the method, and the Gradle output does not show it. This can happen here:DialerWebviewServiceTest.callbacksCannotResumeADestroyedViewOrRescheduleKeepAliveis written as(): Unit = Fixture().use { ... }because its last call returns aBoolean; without the: Unit, JUnit 4 rejects it, and Jupiter would silently not run it.The setting turns every Jupiter discovery warning into a failure of the test task, so a blank
@DisplayNameor a malformed@Tagfails it too; the tests use neither today. When it triggers, the task reports a singleinitializationError, and the test report lists the issues. The key is marked experimental in JUnit 6, so the comment next to it says how to re-check it after a JUnit upgrade.Open pull requests
14 open pull requests add JUnit 4 tests, for example #5903, #6135, #6252 and #6263. After this is merged, those tests will not compile until they get the replacements from the table above. CI builds only the APKs and will not show this;
:app:testPlaystoreDebugUnitTestwill. The JUnit Vintage engine, which would keep running JUnit 4 tests unchanged, is deprecated as of JUnit 6.0, so this PR does not add it.The
junitline inlibs.versions.tomlis next to thecoreKtxline changed by #6271, so whichever of the two is merged second needs a one-line rebase. With #6272–#6275 this merges cleanly.Verification
On Windows with JDK 21, as in CI:
:app:testPlaystoreDebugUnitTestand:app:testFdroidDebugUnitTest: 98 tests, 0 failures, 0 skipped. The executed test classes and methods, read from the XML reports, are the same set as on master under JUnit 4.@Test fun probe() = listOf(1)fails the unit test task with aDiscoveryIssueExceptionnaming the method; without the setting the task passes and the method does not run.:app:assemblePlaystoreDebugand:app:licenseFdroidReleaseReportsucceed. The app's compile and runtime classpaths, debug and release in both flavors, are the same before and after; the license report lists no test dependencies.