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

Unable to run tests #163

Open
PiotrRaszkowski opened this issue Oct 17, 2024 · 5 comments
Open

Unable to run tests #163

PiotrRaszkowski opened this issue Oct 17, 2024 · 5 comments

Comments

@PiotrRaszkowski
Copy link

PiotrRaszkowski commented Oct 17, 2024

When I am trying to run:

E5108: Error executing lua .../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message:                                                                                                                                                
...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:38: attempt to index upvalue 'client' (a nil value)                                                                                                                                                                                                                
stack traceback:                                                                                                                                                                                                                                                                                                               
        ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua: in function <...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:25>                                                                                                                                                                              
        ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:39: in function 'get_tree_from_args'                                                                                                                                                                                                                       
        ...al/share/nvim/lazy/neotest/lua/neotest/consumers/run.lua:80: in function 'func'                                                                                                                                                                                                                                     
        .../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:173: in function <.../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:172>                                                                                                                                                                         
stack traceback:                                                                                                                                                                                                                                                                                                               
        [C]: in function 'error'                                                                                                                                                                                                                                                                                               
        .../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:100: in function 'close_task'                                                                                                                                                                                                                              
        .../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:122: in function 'step'                                                                                                                                                                                                                                    
        .../piotr/.local/share/nvim/lazy/nvim-nio/lua/nio/tasks.lua:150: in function 'run'                                                                                                                                                                                                                                     
        [string ":lua"]:1: in main chunk                                                                             

I have no idea what Is going on.

This is my lua config:

return {
	{
		"rcasia/neotest-java",
		ft = "java",
		dependencies = {
			"mfussenegger/nvim-jdtls",
			"mfussenegger/nvim-dap", -- for the debugger
			"rcarriga/nvim-dap-ui", -- recommended
			"theHamsta/nvim-dap-virtual-text", -- recommended
		},
	},
	{
		"nvim-neotest/neotest",
		dependencies = {
			"nvim-neotest/nvim-nio",
			"nvim-lua/plenary.nvim",
			"antoinemadec/FixCursorHold.nvim",
			"nvim-treesitter/nvim-treesitter",
		},
		opts = {
			adapters = {
				["neotest-java"] = {
					-- config here
				},
			},
		},
	},
}

I am executing:

:lua require("neotest").run.run(vim.fn.expand("%"))
@rcasia
Copy link
Owner

rcasia commented Oct 17, 2024

Can you share your neovim version?

Also have you tried to reinstall the treesitter parser? (:TSInstall java)

@PiotrRaszkowski
Copy link
Author

PiotrRaszkowski commented Oct 17, 2024

TSInstall done, installed (even re-installed, no success).
Neovim version:
NVIM v0.10.2
Build type: Release
LuaJIT 2.1.1727870382

System: MacOS

@rcasia
Copy link
Owner

rcasia commented Oct 17, 2024

Try this steps to share the logs:

  1. Wipe the neotest.log and neotest-java.log file in stdpath("log") or stdpath("data").
  2. Set log_level = vim.log.levels.DEBUG in your neotest setup config.
  3. Reproduce the issue.
  4. Provide the new logs.

@PiotrRaszkowski
Copy link
Author

OK, I fixed the problem... I thin there was something wrong with my configuration.

But I have another problem. In my project we have a custom gradle task -> componentTest. So to run something from command line I need to type:

./gradlew :module1:submodule11:submodule12:componentTest --tests "com.something.something.MyTestClass.someNiceTest"  

Is it possible to achieve that with NeoTest/NeoTest-Java?

My current/working config:

return {
	{
		"rcasia/neotest-java",
		dependencies = {
			"mfussenegger/nvim-jdtls",
			"mfussenegger/nvim-dap", -- for the debugger
			"rcarriga/nvim-dap-ui", -- recommended
			"theHamsta/nvim-dap-virtual-text", -- recommended
		},
	},
	{
		"nvim-neotest/neotest",
		dependencies = {
			"nvim-neotest/nvim-nio",
			"nvim-lua/plenary.nvim",
			"antoinemadec/FixCursorHold.nvim",
			"nvim-treesitter/nvim-treesitter",
			"rcasia/neotest-java",
            -- "vim-test/vim-test",
            -- "nvim-neotest/neotest-vim-test"
        },
		config = function()
			vim.keymap.set(
				"n",
				"<leader>Na",
				"<Esc><Cmd> lua require('neotest').run.attach()<CR>",
				{ desc = "Show running", noremap = true, silent = true }
            )

			vim.keymap.set(
				"n",
				"<leader>Nt",
				"<Esc><Cmd> lua require('neotest').run.run()<CR>",
				{ desc = "Run Test", noremap = true, silent = true }
			)

			vim.keymap.set(
				"n",
				"<leader>Nc",
				"<Esc><Cmd> lua require('neotest').run.run(vim.fn.expand('%'))<CR>",
				{ desc = "Run Class" , noremap = true, silent = true }
			)

			vim.keymap.set(
				"n",
				"<leader>No",
				"<Esc><Cmd> lua require('neotest').output.open()<CR>",
				{ desc = "Show output", noremap = true, silent = true  }
			)


			vim.keymap.set(
				"n",
				"<leader>NO",
				"<Esc><Cmd> lua require('neotest').output.open({ enter = true })<CR>",
				{ desc = "Open output", noremap = true, silent = true  }
			)

			vim.keymap.set(
				"n",
				"<leader>Ns",
				"<Esc><Cmd> lua require('neotest').summary.toggle()<CR>",
				{ desc = "Toggle summary", noremap = true, silent = true  }
			)


			require("neotest").setup({
				log_level = vim.log.levels.DEBUG,
				adapters = {
                    -- require('neotest-vim-test'),
					require("neotest-java")({
						ignore_wrapper = false,
					}),
				},
			})
		end,
	},
}

@rcasia
Copy link
Owner

rcasia commented Oct 27, 2024

In my project we have a custom gradle task -> componentTest.

Is it possible to achieve that with NeoTest/NeoTest-Java?

Not currently. What does that task perform?

lcberg added a commit to lcberg/neovim-config that referenced this issue Dec 17, 2024
somehow different config than the one in description works
found in rcasia/neotest-java#163
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants