Skip to content

Conversation

dnestoro
Copy link
Collaborator

@dnestoro dnestoro commented Aug 22, 2025

Problem: At the moment, every time we run native tests (with both Maven or Gradle), we must run tests on JVM first, in order to collect test-ids required for native run. With more complex tests, this additional step increases time required for tests execution.

Idea: We should use JUnit's dry-run mode to just collect test-ids without executing tests on JVM.

Solution: we can set junit.platform.execution.dryRun.enabled system property to true when executing tests on JVM (maven change, gradle change).

NOTE: Since this approach changes the default behavior, we should bump major version for the next release.

@dnestoro dnestoro self-assigned this Aug 22, 2025
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Aug 22, 2025
@dnestoro dnestoro changed the title Run native tests without running tests on JVM before Run native tests without running tests on JVM first Aug 22, 2025
@dnestoro dnestoro force-pushed the dnestoro/run-native-tests-without-previous-jvm-run branch from 8dfa083 to 05b4dbd Compare August 28, 2025 13:24
@dnestoro dnestoro force-pushed the dnestoro/run-native-tests-without-previous-jvm-run branch from 05b4dbd to 23494be Compare August 28, 2025 13:33

public abstract class AgentUtils {

private static final String STANDARD = "standard";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes in this file are not related to the original purpose of this PR. This is just a small clean-up triggered by some changes in Utils.java class.

@dnestoro dnestoro marked this pull request as ready for review August 29, 2025 11:11
@dnestoro dnestoro requested review from melix, vjovanov and olpaw August 29, 2025 11:11
@dnestoro
Copy link
Collaborator Author

Currently, the tests are failing because there are different number of discovered tests with and without junit.platform.execution.dryRun.enabled while we expect the same number of tests in both cases.

This only happens if the tests are annotated with annotations like @ParameterizedTest or @RepeatedTest.
Test ids discovered without dry-run:

[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testEvery(tests.VintageTests)]
[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testExpectedExceptionCause(tests.VintageTests)]
[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testExpectedException(tests.VintageTests)]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:accessMethodReflectively()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:resourceTest()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:accessFiledReflectively()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:callMethodFromOtherClass()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:repeatedTest(org.junit.jupiter.api.RepetitionInfo)]/[test-template-invocation:#1]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:repeatedTest(org.junit.jupiter.api.RepetitionInfo)]/[test-template-invocation:#2]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:repeatedTest(org.junit.jupiter.api.RepetitionInfo)]/[test-template-invocation:#3]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:testWithExternalFieldSource(java.lang.String)]/[test-template-invocation:#1]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:testWithExternalFieldSource(java.lang.String)]/[test-template-invocation:#2]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:testWithExternalFieldSource(java.lang.String)]/[test-template-invocation:#3]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:test(java.lang.String)]/[test-template-invocation:#1]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:test(java.lang.String)]/[test-template-invocation:#2]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:skipThisTest()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:singleFieldSource(java.lang.String)]/[test-template-invocation:#1]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[test-template:singleFieldSource(java.lang.String)]/[test-template-invocation:#2]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest1()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest2()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest3()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:firstTest()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:secondTest()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:thirdTest()]

Test ids discovered with dry-run:

[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testEvery(tests.VintageTests)]
[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testExpectedExceptionCause(tests.VintageTests)]
[engine:junit-vintage]/[runner:tests.VintageTests]/[test:testExpectedException(tests.VintageTests)]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:accessMethodReflectively()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:resourceTest()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:accessFiledReflectively()]
[engine:junit-jupiter]/[class:tests.ComplexTest]/[method:callMethodFromOtherClass()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:skipThisTest()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest1()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest2()]
[engine:junit-jupiter]/[class:tests.JUnitAnnotationsTests]/[method:beforeAndAfterEachTest3()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:firstTest()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:secondTest()]
[engine:junit-jupiter]/[class:tests.OrderTests]/[method:thirdTest()] 

@sbrannen
Copy link
Collaborator

sbrannen commented Sep 1, 2025

This only happens if the tests are annotated with annotations like @ParameterizedTest or @RepeatedTest.

See junit-team/junit-framework#3164 (comment).

@dnestoro
Copy link
Collaborator Author

dnestoro commented Sep 4, 2025

See junit-team/junit-framework#3164 (comment).

@sbrannen can we somehow extend dryRun mode to collect ids for all tests? If we are going to break some existing support, can we add a new mode (like dryRunAll) to collect all test ids?

I see that dryRun mode is completely separated, but can we follow standard execution pipeline and do something like:

// do all test preparations as in the normal execution
if (!dryRunAll()) {
    executeTest()
}
// post processing where we register test-id

If that idea is not possible to achieve for some reason, do you have some other proposal?

cc @marcphilipp @vjovanov @sdeleuze @melix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The native JUnit tests cannot be executed without the prior run of JVM tests
3 participants