rcasia / neotest-java

Neotest adapter for Java.
MIT License
42 stars 23 forks source link

Can not use dap REPL in Tests #130

Closed beneeng closed 2 months ago

beneeng commented 2 months ago

Hey,

big fan of the project!

I can not seem to get the REPL working properly for tests. For some reason I can not get the value for any variable that is declared in a function. I can however access fields of the current class. It also works for static stuff.

Given the following Java method

    public List<Round> findAll() {
        UUID authenticatedUserId = SecurityAccessor.getAuthenticatedUserId();
        return roundRepository.findByScorecardsOwner(authenticatedUserId);
    }
dap> authenticatedUserId
Cannot evaluate because of compilation error(s): authenticatedUserId cannot be resolved to a variable.
dap> SecurityAccessor.getAuthenticatedUserId()
UUID@76 "9c0675b6-f681-454d-a14d-d0a9985e231d"
  leastSigBits: -6823568433572076771
  mostSigBits: -7203941125252364979
dap> roundRepository.findByScorecardsOwner(SecurityAccessor.getAuthenticatedUserId())
ImmutableCollections$List12@82 size=1
  0: Round@93

This seems to be a dap-adapter configuration error, but I can not figure it out. Glad to help If you have an idea.

Could that be an issue with the way neotest-java sets up DAP?

Best Regards

rcasia commented 2 months ago

Hi @beneeng,

I found out that the javac compilation command was missing the argument -g for it to make the local variables and other symbols recognizable.

Thanks for the catch!

rcasia commented 2 months ago

Feel free to reopen if the problem persists.

beneeng commented 2 months ago

Works like a charm. Thanks!