Dear Apache OFBiz Dev Community Members, I am feeling glad to let you know that I have completed this POC(Migrate Apache OFBiz test suite from JUnit 4 to JUnit 6 (Jupiter)).
The following details will be helpful to you(I have used most of the details shown below in my commit as well): ================================= Migrate Apache OFBiz test suite from JUnit 4 to JUnit 6 (Jupiter) Key changes include: - Assertions Parameter Order: Updated `assertEquals` calls to match the new JUnit 6 method signature. The custom failure message is now passed as the last argument rather than the first `assertEquals(expected, actual, "message")`. - Exception Testing Syntax: Updated `assertThrows` to use JUnit Jupiter API. The following import statement has been changed and introduced jupiter specific import statement: import org.junit.Test; --> import org.junit.jupiter.api.Test; import org.junit.Before; --> import org.junit.jupiter.api.BeforeEach; import org.junit.After; --> import org.junit.jupiter.api.AfterEach; import org.junit.BeforeClass; --> import org.junit.jupiter.api.BeforeAll; import org.junit.AfterClass; --> import org.junit.jupiter.api.AfterAll; import org.junit.Ignore; --> import org.junit.jupiter.api.Disabled; import org.junit.Assert.*; --> import static org.junit.jupiter.api.Assertions.*; Additionally, JUnit 4 assertions with failure messages must have their parameters swapped because JUnit 4 expects (String message, expected, actual) while JUnit 6 Jupiter expects (expected, actual, String message): assertEquals(String, Object, Object) --> assertEquals(Object, Object, String) assertTrue(String, boolean) --> assertTrue(boolean, String) assertFalse(String, boolean) --> assertFalse(boolean, String) assertNotNull(String, Object) --> assertNotNull(Object, String) assertNull(String, Object) --> assertNull(Object, String) assertSame(String, Object, Object) --> assertSame(Object, Object, String) assertNotSame(String, Object, Object) --> assertNotSame(Object, Object, String) And the following changes are also done in this commit: - @Before + @BeforeEach - @After + @AfterEach Important Reference Link: https://docs.junit.org/6.1.0/migrating-from-junit4.html ================================= Here is the PR for this work. https://github.com/apache/ofbiz-framework/pull/1301 https://github.com/apache/ofbiz-framework/compare/trunk...ashishvijaywargiya:ofbiz-framework:junit-migration-from-v4-to-v6 I will wait for Apache OFBiz community members' feedback for the next 2- 4 days, and then I will merge my PR into the ofbiz trunk. Thank you! -- Kind Regards, Ashish Vijaywargiya Vice President of Operations *HotWax Systems* *Enterprise open source experts* http://www.hotwaxsystems.com On Wed, May 27, 2026 at 3:50 PM Ashish Vijaywargiya < [email protected]> wrote: > Dear All, > > Yesterday, I was looking at the following Jira ticket: > https://issues.apache.org/jira/browse/OFBIZ-13138 > > Then I thought to start a discussion around migrating the Apache OFBiz > testing framework from JUnit 4 to JUnit 6 (JUnit Platform + Jupiter > ecosystem). > > Currently, the OFBiz trunk codebase is primarily based on JUnit 4. While > JUnit 4 has served the Java ecosystem well for many years, the JUnit team > has officially placed JUnit 4 into maintenance mode(see reference link > below). According to the official JUnit project, only critical bug fixes > and security updates are expected going forward, while active innovation > and ecosystem improvements are focused on the JUnit Platform and Jupiter > ecosystem. > > Because of this, migrating OFBiz to JUnit 6 could provide long-term > benefits in maintainability, modernization, ecosystem alignment, and > testing capabilities. > > Some key benefits of migrating to JUnit 6 include: > > 1. Modern Testing Architecture > JUnit 6 is built on the JUnit Platform architecture, which provides: > > * better modularity, > * improved extensibility, > * cleaner integrations, > * and modern testing infrastructure. > > 2. Gradual Migration Support > JUnit Vintage allows existing JUnit 4 tests to continue running while new > tests are written using Jupiter APIs. > This enables incremental migration without requiring a complete rewrite of > the entire OFBiz test suite. > > 3. Better Test Organization > JUnit Jupiter introduces modern testing features such as: > > * @Nested tests, > * @DisplayName, > * grouped assertions using assertAll(), > * dynamic tests, > * and cleaner lifecycle handling. > > These features improve the readability and maintainability of complex test > suites. > > 4. Improved Extension Model > - JUnit 6 replaces the older Runner and Rule model with a much cleaner > extension architecture. > - This makes custom testing utilities easier to develop and maintain. > > 5. Enhanced Parameterized Testing > - JUnit Jupiter significantly improves support for parameterized tests > using: > > * CSV sources, > * method sources, > * enum sources, > * and custom argument providers. > > This can help reduce repetitive test code across OFBiz modules. > > 6. Dependency Injection Support > - JUnit Jupiter provides built-in parameter injection support for > lifecycle methods and test methods. > - This helps simplify test setup logic and reduces boilerplate code. > > 7. Conditional Test Execution > - JUnit 6 supports conditional execution annotations such as: > > * @EnabledOnOs, > * @EnabledOnJre, > * @EnabledIfEnvironmentVariable, > * and @DisabledIfSystemProperty. > > These features are useful for CI/CD pipelines and environment-specific > test execution. > > 8. Parallel Test Execution > - Modern JUnit versions provide better support for parallel execution > which can help reduce overall CI execution time for large test suites. > > 9. Improved IDE and Tooling Support > - Modern IDEs and build tools provide much stronger support for JUnit > Jupiter: > > * improved debugging, > * richer test reporting, > * enhanced navigation, > * better parameterized test visualization, > * and improved test discovery. > > 10. Better Ecosystem Alignment > - Most modern Java frameworks, libraries, plugins, and testing utilities > are actively aligned with the JUnit Platform ecosystem. > - Migrating OFBiz helps keep the project aligned with modern Java > development practices. > > 11. Unified and Cleaner Dependency Management > - JUnit 6 provides unified versioning across Platform, Jupiter, and > Vintage modules, which simplifies dependency management and reduces > compatibility complexity. > > 12. Long-Term Sustainability > - Since JUnit 4 is now in maintenance mode, continued reliance on it > increases long-term technical debt. > - Migrating to JUnit 6 helps future-proof the OFBiz testing infrastructure. > > A few reference links: > https://docs.junit.org/6.1.0/migrating-from-junit4.html > https://github.com/junit-team/junit4/blob/main/README.md > https://junit.org/ > > I will work on this POC and will share updates soon with the OFBiz > community. > > If you have additional thoughts on this topic, please share. > Thank you. > > -- > Kind Regards, > Ashish Vijaywargiya > Vice President of Operations > *HotWax Systems* > *Enterprise open source experts* > http://www.hotwaxsystems.com > >
