[BUG] Can't run tests in subapp of a basic gradle project through summary window
NeoVim Version NVIM v0.11.0 Build type: RelWithDebInfo LuaJIT 2.1.1741730670 Run "nvim -V1 -v" for more info
Describe the bug
In a multi-project Gradle setup (e.g. the default one produced by gradle init with a structure like rootProject -> app), running tests using the Neotest summary panel fails with an error referencing a "non-existing project," even though the project exists and tests run successfully using neotest.run.run() or from the test panel after opening nvim in the /app subdirectory.
This appears to happen because neotest-java can't resolve the correct project name when tests are triggered from the root directory through the summary view.
Steps to reproduce the behavior:
- Create a java application using
gradle init --type java-applicationand choosing all of the defaults - Open nvim in its root directory
- Open the neotest summary window
- Pick any scope - app subproject/AppTest/test function and press r to run the tests.
- See error
Expected behavior
Tests should run from the summary panel regardless of current working directory, as long as the project structure is valid and recognized by Gradle and jdtls.
Logs
Error message showing up in :Messages:
Error 04:31:23 PM msg_show.lua_error Error executing vim.schedule lua callback: ...vim/lazy/neotest-java/lua/neotest-java/command/jdtls.lua:46: {
code = -32001,
data = {
message = "Launch configuration 1746286283370 references non-existing project gradle-example."
},
message = "Launch configuration 1746286283370 references non-existing project gradle-example.",
<metatable> = {
__tostring = <function 1>
}
}
stack traceback:
[C]: in function 'assert'
...vim/lazy/neotest-java/lua/neotest-java/command/jdtls.lua:46: in function 'handler'
/usr/share/nvim/runtime/lua/vim/lsp/client.lua:679: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
Additional context
If you could point me in the right direction and this isn't a difficult fix, I would love to help fix the bug and make a contribution. I doubt this requires much overhead since the project is resolved properly when running neotest.run.run(), this behavior should probably be mirrored in the test summary.