neotest-java
neotest-java copied to clipboard
Fix running tests in multi-project builds
With the latest plugin version, running tests in my multi-project gradle build fails.
The project consists of a number gradle sub-projects like com.company.app.web.server.<component>
for about 10 components. Each of these then has src/test/java
.
cat: build/neotest-java/classpath.txt: No such file or directory
error: --class-path requires an argument
Usage: javac <options> <source files>
use --help for a list of possible options
The statusline briefly shows src/test/java is not accessible by the current user!
, then Error reading file: /tmp/neotest-java/<some kind of id>/TEST-junit-jupiter.xml
This is my Lazy config for neotest:
return {
{
'rcasia/neotest-java',
ft = 'java',
dependencies = {
'nvim-neotest/neotest',
dependencies = {
'nvim-neotest/nvim-nio',
'nvim-lua/plenary.nvim',
'antoinemadec/FixCursorHold.nvim',
'nvim-treesitter/nvim-treesitter',
},
},
config = function()
require('neotest').setup {
adapters = {
require 'neotest-java' {
ignore_wrapper = false, -- whether to ignore maven/gradle wrapper
},
},
}
vim.keymap.set('n', '<leader>tp', function()
require('neotest').run.run(vim.uv.cwd())
end, { desc = '[T]est [P]project', noremap = true })
vim.keymap.set('n', '<leader>tf', function()
require('neotest').run.run(vim.fn.expand '%')
end, { desc = '[T]est [F]ile', noremap = true })
vim.keymap.set('n', '<leader>tr', function()
require('neotest').run.run()
end, { desc = '[T]est [R]un', noremap = true })
vim.keymap.set('n', '<leader>ts', function()
require('neotest').run.stop()
end, { desc = '[T]est [S]top', noremap = true })
vim.keymap.set('n', '<leader>ta', function()
require('neotest').run.attach()
end, { desc = '[T]est [A]ttach', noremap = true })
vim.keymap.set('n', '<leader>to', function()
require('neotest').output.open()
end, { desc = '[T]est output [O]pen', noremap = true })
end,
},
}
build/neotest-java/classpath.txt
does exist in the working directory, but is empty.
Version v.1.10.0
still works as before.