nvim-coverage icon indicating copy to clipboard operation
nvim-coverage copied to clipboard

Add java jacoco coverage support

Open ColdMacaroni opened this issue 1 year ago • 1 comments

This is something I pulled together in a couple hours. Only tested with a jacocoTestReport.xml file generated by the gradle plugin. Added some options to configure stuff.

Uses https://lunarmodules.github.io/luaexpat/ to parse XML. I tried to use lua-xmlreader but i could not get it to compile on my computer.

I'm leaving this PR as a draft because I don't really have the time to write the docs and make sure everything is working correctly and like up to spec, but it's functional enough that I think it's worth sharing. Hopefully I can tidy up the code a little and actually write docs once i can find some time, but if anyone feels like writing fixes and such that'd be really cool i think. I haven't seen any glaring errors tho,

(a little unrelated but i really like this plugin's approach to extensibility :saluting_face:)

ColdMacaroni avatar May 14 '24 14:05 ColdMacaroni

I know this is an older discussion, but I'm having trouble getting this to work for myself, I've installed the plugin like this:

    use({
        "ColdMacaroni/nvim-coverage",
        requires = "nvim-lua/plenary.nvim",
        config = function()
            require("coverage").setup({
                commands = true,
                lang = {
                    coverage_file = vim.fn.getcwd() .. "\\target\\site\\jacoco\\jacoco.xml"
                }
            })
        end,
    })

But when I execute :Coverage when I have a java file open it'll keep telling me Coverage report not available for filetype java

Could you help me getting set up?

BasBouwhuis-sf avatar Sep 10 '24 10:09 BasBouwhuis-sf

Hi @BasBouwhuis-sf!

I continuated the work in #59.

Btw, your setup config should have something more like:

{
            commands = true,
            lang = {
                java = {
                  dir_prefix = "src\\main\\java",
                  coverage_file = vim.fn.getcwd() .. "\\target\\site\\jacoco\\jacoco.xml"
                }
            }
}

rcasia avatar Sep 27 '24 21:09 rcasia

I've been really busy with uni so I haven't been able to help debug or work on this. Thank you for picking it up!

Also, @rcasia, thank you for neotest-java! It helped me through many courses

ColdMacaroni avatar Sep 29 '24 01:09 ColdMacaroni

Closing in favour of #59

ColdMacaroni avatar Oct 03 '24 00:10 ColdMacaroni