Skip to content

Revise TestConventions so that existing JUnit options are copied instead of overridden #34827

Closed
@sbrannen

Description

@sbrannen

Overview

As I mentioned in commit e384389, our TestConventions implementation currently overrides any pre-configured JUnit Platform options in an existing Gradle test task.

Actually, it overrides any existing test task configuration that TestConventions also happens to set. So, this is not limited to JUnit Platform options, but the JUnit Platform options are typically the most important configuration options that should be retained.

private void configureTests(Project project, Test test) {
test.useJUnitPlatform();
test.include("**/*Tests.class", "**/*Test.class");
test.setSystemProperties(Map.of(
"java.awt.headless", "true",
"io.netty.leakDetection.level", "paranoid"
));
if (project.hasProperty("testGroups")) {
test.systemProperty("testGroups", project.getProperties().get("testGroups"));
}
test.jvmArgs(
"--add-opens=java.base/java.lang=ALL-UNNAMED",
"--add-opens=java.base/java.util=ALL-UNNAMED",
"-Xshare:off"
);
}

Specifically, TestConventions overrides configuration for the test tasks in spring-context.gradle and spring-test.gradle. Consequently, configuration such as includeEngines "junit-jupiter", "junit-vintage" is not honored, and the test task will erroneously succeed without the presence of the JUnit Vintage test engine, which will silently ignore tests such as SpringAtInjectTckTests (for the @Inject TCK) and all JUnit 4 tests in the spring-test module.

Thus, we should revise the implementation of TestConventions so that existing JUnit options are copied instead of overridden.

Related Issues

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions