andy-bell101 / neotest-java

Java plugin for Neotest
MIT License
11 stars 4 forks source link

Feedback #3

Open guillaumeLamanda opened 1 year ago

guillaumeLamanda commented 1 year ago

Hi 👋

I saw this project here, and @andy-bell101 was asking for feedback.

I sporadically work on a maven project with JUnit tests, so I try it.

For now, when I try to open the summary I get this error:

   Error  09:12:37 notify.error lazy.nvim Failed to run `config` for neotest

...l/share/nvim/lazy/neotest-java/lua/neotest-java/init.lua:300: attempt to call global 'is_callable' (a nil value)

# stacktrace:
  - /neotest-java/lua/neotest-java/init.lua:300 _in_ **setter**
  - /neotest-java/lua/neotest-java/init.lua:311
  - ~/.config/nvim/lua/plugins/testing.lua:61 _in_ **config**

And when I try to run a test, I have the following error:

   Error  09:15:27 msg_show.emsg E5108: Error executing lua: ...im/lazy/LazyVim/lua/lazyvim/plugins/extras/test/core.lua:81: attempt to index field 'run' (a nil value)
stack traceback:
    ...im/lazy/LazyVim/lua/lazyvim/plugins/extras/test/core.lua:81: in function <...im/lazy/LazyVim/lua/lazyvim/plugins/extras/test/core.lua:81>

The project use maven.

Thanks for the initiative with this project, I hope this feedback will help

andy-bell101 commented 1 year ago

Looks like I just assumed the is_callable function exists from looking at someone else's code but it doesn't. I'll get a fix in tonight. Not sure about the second error. Hopefully fixing the first error fixes the second one?

andy-bell101 commented 1 year ago

Ok the first issue is fixed in the latest commit. Hopefully the second issue resolves itself after you update

guillaumeLamanda commented 1 year ago

I tried your update. The test wasn't running. I fixed it from the PR linked above.
Now, I have another issue: the test success but the plugin tells it has failed.
I also have the following notification:

17:11:16 msg_show /Users/guillaumelamanda/zenika/pleenk/pleenk-redesign/projects/backend/build/test-results/test is not accessible by the current user!

The test result is in target/surefire-reports/TEST-com.pleenk.backend.modules.topup.domain.TopUpTest.xml.

andy-bell101 commented 1 year ago

Looks like Maven puts things in a different place to Gradle. I'll have to add some logic in so it can find the files. Is this project something I can access or is it private? Would make testing it easier

guillaumeLamanda commented 1 year ago

Sadly the project is private. 😬
I fixed the maven example in the repo (thanks to my colleague @madbrain 🎉 ) in the PR

andy-bell101 commented 1 year ago

Just merged. Thanks for your help :) I'll see if I can find a public Maven based project somewhere

asmodeus812 commented 10 months ago

One thing to note, not sure if handled already, but the java_home has to be explicitly set/resolved based on the project's current settings, otherwise it will run maven for example with whichever is the default one in the current env. This might be a problem since you might have one project running or being configured for java11, but have a different java_home configured in your env. On a daily basis, i interact with multiple projects configured with different versions of java, from 8 to 20. The way i had resolved this in the past, for an adhoc build solution in my config, is pulling the current runtime from jdtls, using a request command - "java.project.getSettings", with the following arguments local COMPILER = "org.eclipse.jdt.core.compiler.source" local LOCATION = "org.eclipse.jdt.ls.core.vm.location"

The request will return the location of the vm, which is the one for the current project, which can then be set to the java_home in the env table, before running jobstart for mvn. That will only work if the user has configured the vm locations when creating the jdtls configuration - for example. Probably relevant for gradle, but i know maven picks up only java_home, you can't really pass it as command line arg to mvn itself, to tell it which sdk to use.

{
    "java": {
        "configuration": {
            "runtimes": [
                {
                    "default": true,
                    "name": "JavaSE-17",
                    "path": "/home/linuxbrew/.linuxbrew/Cellar/openjdk@17/17.0.7/libexec"
                }
            ]
        }
    }
}