Skip to content

Fix unitTest task not running the test source set - #2073

Closed
loggk wants to merge 1 commit into
opensearch-project:mainfrom
loggk:fix/unit-test-source-set-wiring
Closed

Fix unitTest task not running the test source set#2073
loggk wants to merge 1 commit into
opensearch-project:mainfrom
loggk:fix/unit-test-source-set-wiring

Conversation

@loggk

@loggk loggk commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Description

./gradlew unitTest runs 1 test class instead of 170 — the tests under src/test/java are never executed, locally or in CI.

unitTest is created with task<Test>("unitTest"), which has no testClassesDirs or classpath. The only place they get populated is the JDK-21 block, which appends to that empty base:

tasks.named<Test>("unitTest") {
    testClassesDirs += java21.output.classesDirs
    classpath = sourceSets["java21"].runtimeClasspath
}

So the task resolves to the java21 source set alone. This is a regression from #968, where those two lines were moved off tasks.test — whose testClassesDirs the java plugin populates, making += correct — and onto unitTest/integrationTest, which have no base.

Changes

Set testClassesDirs and classpath on unitTest from the test source set, so the JDK-21 block appends to it rather than defines it.

./gradlew :java-client:unitTest on JDK 21 (Temurin 21.0.11), counted from java-client/build/test-results/unitTest/:

classes tests failures
before 1 1 0
after 170 426 0

All 426 pass, so no other change is needed to re-enable them. RequestOptionsTest from src/test/java11 still runs, and the excludeTestsMatching filter still keeps integTest classes out.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Logan Kennedy <kennedylogan22@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant