Neotest adapter for Java, using JUnit.
- ✅ Maven and Gradle projects
- ✅ Multimodule projects
- ✅ Integrated with
nvim-dapfor test debugging.
Check ROADMAP.md to see what's coming!
- Make sure you have installed nvim-treesitter parsers. Use
:TSInstall java - Add neotest-java to your config:
lazy.nvim plugin manager example
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",
},
config = function()
require("neotest").setup({
adapters = {
require("neotest-java")({
-- config here
}),
},
})
end,
}
}- Run
:NeotestJava setup
Note
It will download the JUnit standalone jar from https://mvnrepository.com/artifact/org.junit.platform/junit-platform-console-standalone
Autoinstall requires Neovim v0.12.0+ (nightly) - The vim.fn.sha256() function used for checksum verification requires this version. For older versions, manually download the JAR file.
| Option | Type | Default | Description |
|---|---|---|---|
junit_jar |
string? |
stdpath("data") .. /nvim/neotest-java/junit-platform-console-standalone-[version].jar |
Path to the JUnit Platform Console standalone JAR. |
jvm_args |
string[] |
{} |
Additional JVM arguments passed when running tests. |
incremental_build |
boolean |
true |
Enable incremental compilation before running tests. |
test_classname_patterns |
string[] |
{"^.*Tests?$", "^.*IT$", "^.*Spec$"} |
Regular expressions used to include only classes whose names match these patterns. Classes not matching any pattern will be ignored. |
Feel free to contribute to this project by creating issues for bug reports, feature requests, or suggestions.
You can also submit pull requests for any enhancements, bug fixes, or new features.
Your contributions are greatly appreciated. See CONTRIBUTING.md