You open Neovim, your preferred editor, with the intention of running tests without having to leave your preferred environment.
This Neovim plugin, java-maven-test.nvim, integrates with telescope.nvim and nvim-treesitter to facilitate interactive fuzzy searching and execution of Java tests within a class.
java-maven-test.nvim/
├── LICENSE
├── lua
│ └── java-maven-test
│ ├── commands.lua # Commands exposed to Neovim
│ ├── ui.lua # UI logic (pickers and layout)
│ ├── init.lua # Plugin entry point
│ ├── notify.lua # Notification-related logic
│ ├── mvn.lua # Maven-related logic
│ └── util.lua # Utility functions
└── README.md
- Execute test case under the cursor
- Execute all test in a given class
- Fuzzy find trough all tests in a class and pick which one to execute
- Notifications message about test results
- Make sure you have Neovim v0.9.0 or greater. ❗
- Dependecies: treesiter && telescope && plenary (telescope dep)
- Install using you plugin manager
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'rcarriga/nvim-notify'
Plug 'jkeresman01/java-maven-test.nvim' use {
'nvim-telescope/telescope.nvim', tag = '0.1.8',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}
use 'nvim-treesitter/nvim-treesitter'
use 'rcarriga/nvim-notify'
use 'jkeresman01/java-maven-test.nvim'Following commands have been exposed to Neovim:
Commands
:MavenTest -- Launch picker (select your test case from UI)
:MavenTestAtCursor -- Execute test at cursor
:MavenTestAllInClass -- Execute all tests in class
Set the keybindings as you see fit, here is one example:
require('java-maven-test').setup()
vim.keymap.set("n", "<leader>ft", "<cmd>MavenTest<CR>")
vim.keymap.set("n", "<leader>rt", "<cmd>MavenTestAtCursor<CR>")
vim.keymap.set("n", "<leader>ra", "<cmd>MavenTestAllInClass<CR>")| Keybindings | Action |
|---|---|
<leader>rt |
Execute test under the cursor |
<leader>ra |
Execute all tests in currently opened class |
<leader>ft |
Fuzzy find trough tests in a given class and execute selected one |