Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running tests in multi-project builds #100

Open
JonaLoeffler opened this issue Apr 30, 2024 · 1 comment
Open

Fix running tests in multi-project builds #100

JonaLoeffler opened this issue Apr 30, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JonaLoeffler
Copy link

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.

@rcasia rcasia added the bug Something isn't working label May 2, 2024
@rcasia rcasia changed the title Fix running tests in multi-project gradle builds Fix running tests in multi-project builds Jun 22, 2024
@steffsommer
Copy link

This might be the biggest blocker for people to use this plugin in real world settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants