When I try running gradle test
, I get the following output:
$ gradle test :ro:compileJava UP-TO-DATE :ro:processResources UP-TO-DATE :ro:classes UP-TO-DATE :ro:jar :compileJava :processResources UP-TO-DATE :classes :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test ro.idea.ToggleTest > testIsAd FAILED java.lang.NoClassDefFoundError at ToggleTest.java:13 Caused by: java.lang.ClassNotFoundException at ToggleTest.java:13 ro.idea.ToggleTest > testToggle FAILED java.lang.NoClassDefFoundError at ToggleTest.java:13 2 tests completed, 2 failed :test FAILED
So I want to check my classpath to see whether my classpath is wrong or not.
My question is: How can I list the classpath at test
time with a Gradle task?
Annotation Type ClasspathMarks a property as specifying a JVM classpath for a task. This annotation should be attached to the getter method in Java or the property in Groovy. Annotations on setters or just the field in Java are ignored. For jar files, the normalized path is empty.
Gradle executes tests in a separate ('forked') JVM, isolated from the main build process. This prevents classpath pollution and excessive memory consumption for the build process. It also allows you to run the tests with different JVM arguments than the build is using.
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.
You can list test runtime dependencies with:
gradle dependencies --configuration=testRuntime
Or, if you want to see the actual files:
task printClasspath { doLast { configurations.testRuntime.each { println it } } }
Also, to list the classpath for the main (non-test) application run use:
run << { doLast { configurations.runtime.each { println it } } }
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