Skip to content

Conversation

@chennu2020
Copy link
Contributor

@chennu2020 chennu2020 commented Jul 25, 2025

JUnit 5 support for Java SDK with backward compatibility.

cmaddela added 4 commits July 24, 2025 18:00
- Upgrade junit-bom from 5.10.0 to 5.13.4
- Updates both provided and testImplementation dependencies
- Ensures latest JUnit 5 features and bug fixes are available
- Added JUnit 5 TestPipelineExtension support to 2.67.0 highlights and features
- Added JUnit BOM version 5.13.4 (new addition, not update)
- Removed duplicate entries from 2.68.0 since feature releases in 2.67.0
- Maintains backward compatibility with existing JUnit 4 TestRule-based tests
Replace placeholder #TBD references with the actual GitHub issue apache#18733
for JUnit 5 support implementation
@gemini-code-assist
Copy link
Contributor

Important

Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services.

@github-actions github-actions bot added the java label Jul 25, 2025
cmaddela added 2 commits July 25, 2025 10:06
- Explicitly specify JUnit 4 version in JMS module to avoid conflicts with JUnit 5 BOM
- Ensures backward compatibility with existing JUnit 4 tests
- Resolves precommit failures in ':sdks:java:io:jms:test'
- Improved TestPipelineExtension with factory methods for better usability
- Added JUnit 4/5 bridge using vintage engine with explicit version
- Fixed JUnit 4 compatibility issues with existing test modules
- Enhanced extension to work with both injection and direct instantiation
- Fixed TestPipelineTest failures for complete JUnit 5 compatibility
@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

- Use minimal JUnit 5 dependencies (junit-jupiter-api, junit-jupiter-engine 5.10.0)
- Remove JUnit BOM and vintage engine to avoid compatibility conflicts
- Keep existing JUnit 4 infrastructure completely untouched
- Fix JMS module with explicit JUnit 4.13.2 dependency to prevent conflicts
- Update changelog to reflect conservative approach
- Ready for comprehensive testing in GitHub CI environment
@github-actions
Copy link
Contributor

Assigning reviewers:

R: @chamikaramj for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2025

Reminder, please take a look at this pr: @chamikaramj

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @Abacn for label java.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

tracking bug: #18733.

Thanks for taking this long standing issue forward. And agree with the approach of supporting both junit 4/5 for compatibility.

I would suggest taking the chance to revisit the situation of Beam java core depending on junit/hamcrest and other test dependencies. There is plan to separate non-core dependencies out of Java core: #34554 at least we can do for new junit5 dependencies. (Currently every Beam java user have these test dependencies even for production pipeline which is not ideal).

I would recommend to create a new module e.g. sdks/java/testing/junit (naming can be discussed) dedicated for junit 5 test pipelines, and put TestPipelineExtensions there. Utimately we may move TestPipeline and any test fixtures out of Java core (but this is a breaking change, so probably in Beam 3)

@liferoad
Copy link
Contributor

liferoad commented Aug 6, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces JUnit 5 support for the Java SDK, which is a great enhancement for modernizing the testing framework. The implementation includes a new TestPipelineExtension for JUnit 5, updates to the build files, and documentation. My review focuses on the correctness of the build configuration and the maintainability of the new extension.

I've identified a high-severity issue in the build.gradle file where useJUnit() is used instead of useJUnitPlatform(), which will prevent JUnit 5 tests from running. I've also pointed out a medium-severity maintainability issue in TestPipelineExtension.java regarding the use of Optional in the ExtensionContext.Store, with a suggestion for refactoring.

…move JUnit 5 deps from core; deprecate core stub; normalize JMS JUnit dep; add managed JUnit aliases; rename artifact to beam-sdks-java-testing-junit; update CHANGES.md; refactor ExtensionContext.Store usage (no Optional)
@github-actions github-actions bot added the jms label Aug 11, 2025
Copy link
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Thank you!

@Abacn Abacn merged commit c371236 into apache:master Aug 12, 2025
27 checks passed
@chennu2020 chennu2020 deleted the junit5-support branch August 12, 2025 18:34
parveensania pushed a commit to parveensania/beam-dp that referenced this pull request Aug 17, 2025
* JUnit 5 support.

---------

Co-authored-by: cmaddela <chennakeshavlu.maddela@davita.com>
DKER2 pushed a commit to DKER2/beam that referenced this pull request Aug 20, 2025
* JUnit 5 support.

---------

Co-authored-by: cmaddela <chennakeshavlu.maddela@davita.com>
@Abacn Abacn mentioned this pull request Sep 24, 2025
3 tasks
Abacn added a commit that referenced this pull request Sep 25, 2025
* Fix JUnit 5 module

* Revert TestPipeline change in #35688 and move shared logic into package-private
  methods

* Exercise tests on precommit

* Publish javadoc

* Fix checkstyle, fix tests
@idc101
Copy link

idc101 commented Sep 29, 2025

I am trying to use this in v2.68 but the validation is still looking for the junit 4 Rule:

Is your TestPipeline declaration missing a @Rule annotation? Usage: @Rule public final transient TestPipeline pipeline = TestPipeline.create();
java.lang.IllegalStateException: Is your TestPipeline declaration missing a @Rule annotation? Usage: @Rule public final transient TestPipeline pipeline = TestPipeline.create();
	at org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkState(Preconditions.java:512)
	at org.apache.beam.sdk.testing.TestPipeline.run(TestPipeline.java:414)
	at org.apache.beam.sdk.testing.TestPipeline.run(TestPipeline.java:366)

Recreate with:

import org.apache.beam.sdk.testing.NeedsRunner;
import org.apache.beam.sdk.testing.TestPipeline;
import org.apache.beam.sdk.testing.TestPipelineExtension;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

 @ExtendWith(TestPipelineExtension.class)
 public class DeDuplicateTest implements Serializable {
    @Test
    @Category(NeedsRunner.class)
    public void testBasicDeDuplicate(TestPipeline p) {
        p.run();
    }

@Abacn
Copy link
Contributor

Abacn commented Sep 29, 2025

I am trying to use this in v2.68 but the validation is still looking for the junit 4 Rule:

Fixed in #36258. Unfortunately this new module isn't functioning in Beam 2.68. Will be fixed in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants