return { { 'nvim-neotest/neotest', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-neotest/nvim-nio', 'nvim-treesitter/nvim-treesitter', 'nvim-neotest/neotest-python', 'alfaix/neotest-gtest', 'andythigpen/nvim-coverage', }, event = 'VeryLazy', config = function() local neotest = require('neotest') neotest.setup({ adapters = { require('neotest-python')({ runner = 'pytest', dap = { justMyCode = false }, args = { '-v', '--tb=short' }, -- Discover tests in tests/ directory pytest_discover_instances = true, }), require('neotest-gtest').setup({ debug_adapter = 'codelldb', }), }, output = { open_on_run = false }, summary = { open = 'botright vsplit | vertical resize 60' }, }) local ok_cov, coverage = pcall(require, 'coverage') if ok_cov then coverage.setup({ auto_reload = true, }) end -- Keymaps (defined after setup to ensure modules are available) vim.keymap.set('n', 'tn', function() neotest.run.run() end, { desc = 'Test: Run nearest' }) vim.keymap.set('n', 'tf', function() neotest.run.run(vim.fn.expand('%')) end, { desc = 'Test: Run file' }) vim.keymap.set('n', 'ta', function() neotest.run.run(vim.fn.getcwd()) end, { desc = 'Test: Run all (cwd)' }) vim.keymap.set('n', 'td', function() neotest.run.run({ strategy = 'dap' }) end, { desc = 'Test: Debug nearest' }) vim.keymap.set('n', 'tx', function() neotest.run.stop() end, { desc = 'Test: Stop' }) vim.keymap.set('n', 'ts', function() neotest.summary.toggle() end, { desc = 'Test: Toggle summary' }) vim.keymap.set('n', 'to', function() neotest.output.open({ enter = true, auto_close = false }) end, { desc = 'Test: Show output' }) vim.keymap.set('n', 'tw', function() neotest.watch.toggle(vim.fn.expand('%')) end, { desc = 'Test: Watch file' }) vim.keymap.set('n', ']t', function() neotest.jump.next({ status = 'failed' }) end, { desc = 'Test: Next failed' }) vim.keymap.set('n', '[t', function() neotest.jump.prev({ status = 'failed' }) end, { desc = 'Test: Prev failed' }) vim.keymap.set('n', 'tC', function() local ok, cov = pcall(require, 'coverage') if ok then cov.toggle() end end, { desc = 'Test: Toggle coverage' }) vim.keymap.set('n', 'tL', function() local ok, cov = pcall(require, 'coverage') if ok then cov.load(true) end end, { desc = 'Test: Load coverage' }) end, }, }