Skip to content
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

Implement JUnit5 support and parameterize tests #4473

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

blorente
Copy link
Collaborator

@blorente blorente commented Feb 20, 2023

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.
    • Well, this has some refactoring, mostly of the test code to make it easier to parameterize.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: #4433

Description of this change

Luckily, JUnit 4 test filters are compatible with JUnit 5.

Therefore, the only things that this PR needs to do are:

  • Change JUnitTestHeuristic to account for JUnit 5.

  • Change the test filter generators to account for JUnit 5 as well.

  • Change the testbed so that it also tests against JUnit 5 code:

    • Introduce JUnitTestUtils, a utility class to set up test repositories with JUnit 5 or 4 code.
    • Introduce BlazeJUnitRunConfigurationProducerTestCase, to remove parameterization boilerplate for the Run Configuration Producer tests.
    • Parameterize relevant integration tests (either with the base class mentioned above, or by hand), to test a set of JUnit versions (currently, 4 and 5). This mostly affects the set up of the code under tests, so we can reuse a lot of the test logic.
    • Introduce JUnit 5 to the java example project.
  • Implement fastbuild support for java_junit5_test:

    • Add the java_junit5_test as an allowed target kind for FastBuild.
    • Capture the main_class attribute in the FastBuild aspect proto.
    • Prefer main_class when building run configurations over the default bazel runner (java_junit5_test uses a custom test runner).

@blorente blorente mentioned this pull request Feb 20, 2023
@sgowroji sgowroji added product: IntelliJ IntelliJ plugin topic: testing awaiting-review Awaiting review from Bazel team on PRs labels Feb 20, 2023
@raoarun
Copy link
Collaborator

raoarun commented Apr 20, 2023

@mai93 please review.

@blorente
Copy link
Collaborator Author

Rebased on top of master and implemented #5550 in the last two commits.

@kermitnirmit
Copy link

kermitnirmit commented Nov 16, 2023

Hi - I'm super interesting in this because I use junit5 and my parameterized tests don't look like this:
image
They are all on the top level instead. I would like this hierarchy.

EDIT: pulled down your version and built it. I don't think this hierarchy/nesting/structure is there for parameterized tests.

@blorente
Copy link
Collaborator Author

Addressed the comments, sorry for the delay but it was hard to find time, as per usual.

@agluszak agluszak self-assigned this Oct 3, 2024
@agluszak agluszak merged commit 842a0ae into bazelbuild:master Oct 3, 2024
6 checks passed
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

6 participants