Skip to content

Deprecate JUnit 4 support in the Spring TestContext Framework #34794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
10 tasks done
sbrannen opened this issue Apr 22, 2025 · 0 comments
Closed
10 tasks done

Deprecate JUnit 4 support in the Spring TestContext Framework #34794

sbrannen opened this issue Apr 22, 2025 · 0 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Apr 22, 2025

Overview

Support for JUnit 4 was introduced in Spring Framework 2.5 in 2007.

JUnit 4 is no longer actively maintained, and the last maintenance release was JUnit 4.13.2 in February 2021.

In addition, JUnit 4 has a Java 1.5 baseline.

Support for JUnit Jupiter (JUnit 5) was introduced in Spring Framework 5.0 in 2017.

JUnit Jupiter was initially released with JUnit 5.0 in September 2017. JUnit Jupiter is actively maintained and has a Java 8 baseline. The last maintenance release was 5.12.2 two weeks ago (April 11, 2025).

Furthermore, the JUnit team is planning to release JUnit 6.0 with a Java 17 baseline later this year (junit-team/junit5#4246).

In light of the above, it is time to phase out our support for JUnit 4 by deprecating it in Spring Framework 7.0 and deprecating it "for removal" in 7.1 or 7.2 (tentatively for removal in Spring Framework 8.0).

Components to Deprecate

  • @IfProfileValue
  • @ProfileValueSourceConfiguration
  • ProfileValueSource and SystemProfileValueSource
  • ProfileValueUtils
  • @Repeat and @Timed
  • TestAnnotationUtils
  • SpringJUnit4ClassRunner and SpringRunner
  • SpringClassRule and SpringMethodRule
  • AbstractJUnit4SpringContextTests and AbstractTransactionalJUnit4SpringContextTests
  • All Statement implementations in the org.springframework.test.context.junit4.statements package

Related Issues

@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement labels Apr 22, 2025
@sbrannen sbrannen added this to the 7.0.0-M5 milestone Apr 22, 2025
@sbrannen sbrannen self-assigned this Apr 22, 2025
sbrannen added a commit that referenced this issue Apr 24, 2025
In Spring Framework 5.2, we migrated most of the test suite from JUnit
4 to JUnit Jupiter; however, prior to this commit, several tests in the
spring-test module were still based on JUnit 4 unnecessarily.

Since we are now planning to deprecate our JUnit 4 support in 7.0, this
commit migrates our remaining JUnit 4 based tests to JUnit Jupiter
whenever feasible. In the process, test classes that previously resided
under the "junit4" package have been moved to new packages directly
under the "org.springframework.text.context" package, and several
classes have been renamed for greater clarity of purpose.

Consequently, the only remaining tests based on JUnit 4 are those tests
that are required to run with JUnit 4 in order to test our JUnit 4
support.

This commit also greatly simplifies exclusions for Checkstyle rules
pertaining to JUnit usage.

See gh-23451
See gh-34794
Closes gh-34813
sbrannen added a commit that referenced this issue Apr 26, 2025
In 49e5c84 I unfortunately overlooked
several JUnit 4 based tests in the `junit4` package that should be
migrated to JUnit Jupiter.

This commit address those remaining test classes.

See gh-23451
See gh-34794
Closes gh-34813
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Apr 26, 2025
@sbrannen sbrannen changed the title Deprecate JUnit 4 support Deprecate JUnit 4 support in the Spring TestContext Framework Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant