You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside src/test/resources there is an arquillian.xml file that has to be expanded by gradle at processTestResources task. When a test is run from within vs code, this doesn't happen and the resource file is used as is. This triggers an error from Junit that basically says that some property is invalid (because it's expanded, i.e. junit see it as ${somePropToExpand}).
Same thing occurs when arquillian.xml is auto generated by a plugin - a gradle plugin can auto create it and put it directly in the buildDir/resources/test dir. When a test is run from within vs code, basically the file is invisible to vs code.
Both of these problems can be corrected by having a:
The project classpath is resolved by buildship (if it's a Gradle project). To help us better understand the problem, would you mind to share a sample project for this issue to us?
First do a gradle clean test. It should complete successfully.
This initial normal build is set to auto generate arquillian.xml at built time, thus: /tmp/sample/src/test/resources/__arquillian.xml is prefixed with __ to ignore it. Such a build doesn't work when executed from vscode, because vscode code thinks this file doesn't exist. But it can be found in $buildDir/resources/test.
Now remove the __ prefix from /tmp/sample/src/test/resources/__arquillian.xml to force gradle to explicitly use it. Make sure you manually set the wlpHome (in my case, project ran from /tmp). The following is observed:
when you do gradle clean test it should complete successfully.
when run from vscode, it will error out because of the properties the need to be expanded. For ex., this is the error i get: java.lang.NumberFormatException: For input string: "${SERVER_PORT}"
if you run gradle processTestResources, you can confirm the property expansion works - the files in $buildDir/resources/test have the proper values.
src/test/resources/arquillian.xml and src/test/resources/persistence.xml have commented out lines - toggle those so that you directly set the values. When run from vscode it will complete successfully.
I can repro this issue and I also tried the project in Eclipse and IntelliJ.
In Eclipse, same error when running the test, but it can successfully run if I use the Delegate to Gradle feature.
In IntelliJ, since it will delegate to Gradle by default, so the test runs successfully.
Seems that we need to support Delegate to Gradle at VS Code side.
Reacted by egvimo, Ali Aminfar, Robin Weinreich, Thomas Stoeber, Marius Filipowski, Wang Yuxuan, Stephen Jackson, Pedro Ribeiro Baptista, technoguy, Lilac__P and 4 more
I have the same problem. A "Delegate to Gradle" Feature would be great!
Reacted by Marius Filipowski, Marcelo Gonçalves, Wang Yuxuan, Pedro Ribeiro Baptista, EternalWind, Brett Lockhart, thomas.howard and Bruno T. Hernandez
Activity
jdneo commentedon Aug 13, 2020
The project classpath is resolved by buildship (if it's a Gradle project). To help us better understand the problem, would you mind to share a sample project for this issue to us?
hrsto commentedon Aug 13, 2020
Attaching the most minimal i could produce.
There's only one test class -
ArquillianInitTest.First do a
gradle clean test. It should complete successfully.This initial normal build is set to auto generate
arquillian.xmlat built time, thus:/tmp/sample/src/test/resources/__arquillian.xmlis prefixed with__to ignore it. Such a build doesn't work when executed from vscode, because vscode code thinks this file doesn't exist. But it can be found in$buildDir/resources/test.Now remove the
__prefix from/tmp/sample/src/test/resources/__arquillian.xmlto force gradle to explicitly use it. Make sure you manually set thewlpHome(in my case, project ran from/tmp). The following is observed:gradle clean testit should complete successfully.java.lang.NumberFormatException: For input string: "${SERVER_PORT}"gradle processTestResources, you can confirm the property expansion works - the files in$buildDir/resources/testhave the proper values.src/test/resources/arquillian.xmlandsrc/test/resources/persistence.xmlhave commented out lines - toggle those so that you directly set the values. When run from vscode it will complete successfully.sample.tar.gz
jdneo commentedon Aug 20, 2020
Here are some findings:
I can repro this issue and I also tried the project in Eclipse and IntelliJ.
In Eclipse, same error when running the test, but it can successfully run if I use the
Delegate to Gradlefeature.In IntelliJ, since it will delegate to Gradle by default, so the test runs successfully.
Seems that we need to support
Delegate to Gradleat VS Code side.egvimo commentedon Feb 22, 2021
I have the same problem. A "Delegate to Gradle" Feature would be great!
ytreister commentedon Aug 15, 2022
Any update on this?
prbpedro commentedon Sep 6, 2022
I have the same problem. A "Delegate to Gradle" Feature would be great!
uk-taniyama commentedon Nov 23, 2022
I tried to call "gardle test" with vscode-gradle but could only get as far as the call.
violetexistence commentedon May 29, 2024
Yes, please!
jdneo commentedon Jun 26, 2024
Update: I'm implementing gradle test delegation recently and it will come very soon
[-]Run test fails with gradle when tasks that process resources are involved.[/-][+]Support Gradle test delegation[/+]jdneo commentedon Aug 5, 2024
The Gradle Test Delegation (both run and debug) has supported now.
To use this feature, you need to install the latest Test Runner for Java and Gradle for Java extension.
To delegate the tests to Gradle, you can set the default testing profile in Testing explorer:


If you do not want to change the default testing profile, you can trigger an one-time execution via:


piotr-rachwalik commentedon Sep 13, 2024
Sheng Chen (@jdneo) I don't see Delegate Test to Gradle option in my VS Code:



Any hints how to enable that feature?
wenytang-ms commentedon Apr 28, 2026
consider upgrade to latest preview of vscode gradle with this issue
3.17.2026042802