I'm using the latest version of Gradle (milestone 9), and I'm trying to figure out how to create a Jar of all test binaries.
From what I've found on the internet, the following should work:
task packageTests(type: Jar) { from sourceSets.test.classes }
However I am getting a -
Cannot get the value of write-only property 'classes' on source set test.
What is the correct way of coding what I'm trying to achieve?
Is the property 'classes' somehow deprecated now ?
How to generate a Test Report. Gradle generates a Test Report automatically when it runs the entire Test Suite. To do the same, run ./gradlew test (or gradlew. bat test from Windows), or run the test Gradle task from your IDE.
By default, Gradle will run all tests that it detects, which it does by inspecting the compiled test classes. This detection uses different criteria depending on the test framework used. For JUnit, Gradle scans for both JUnit 3 and 4 test classes.
Changing sourceSets.test.classes
to sourceSets.test.output
fixes the problem.
In 2021 there is the Kotlin DSL now, so the latest answer looks like:
tasks.register<Jar>("packageTests") { from(sourceSets.test.get().output) }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With