SublimeDebugger icon indicating copy to clipboard operation
SublimeDebugger copied to clipboard

Java: debugging JUnit tests

Open takase1121 opened this issue 3 years ago • 1 comments

I can't figure out a way to debug a JUnit test. I use JUnit 5 as a standalone jar file and I can't figure out how to launch it.

I went and poke around nvim-jdtls' code to find that there's a command to get the appropriate JUnit test command to run (which you can later attach to) but I have no idea how that would work with sublime debugger.

Here's the relevant nvim-jdtls command:

https://github.com/mfussenegger/nvim-jdtls/blob/cc59c194b3c6371e940b8aba9146a068b8035dee/lua/jdtls.lua#L256-L267

takase1121 avatar Sep 26 '22 01:09 takase1121

The Java Debug Adapter is special in that it requires communication with the LSP-side. There might be work necessary in LSP-jdtls in addition to support JUnit in Sublime Debugger.

LDAP avatar Sep 26 '22 14:09 LDAP

This was implemented in the latest LSP-jdtls release. However, something is currently broken in Debugger, see #204.

LDAP avatar Feb 01 '23 12:02 LDAP

Fixed with the latest release. This can be closed @daveleroy

LDAP avatar Feb 04 '23 09:02 LDAP

hmmm still facing the issue when trying to run any kind of JUnit tests via LSP-jdtls with the debugger open...

Unable to start adapter: Unable to connect to LSP client (timed out)

Debugger: v0.9.3 LSP: v1.22.0 LSP-jdtls: v2.0.0

appelgriebsch avatar Feb 08 '23 16:02 appelgriebsch

Can you post your ST console log and LSP log?

LDAP avatar Feb 08 '23 21:02 LDAP

This might just be timing out I think the timeout is something short like 2.5 seconds which could be increased

daveleroy avatar Feb 09 '23 07:02 daveleroy

This might just be timing out I think the timeout is something short like 2.5 seconds which could be increased

Yeah, that sounds like it. Any hint how I can extend the timeout in my setup (just to cross check)?

appelgriebsch avatar Feb 09 '23 10:02 appelgriebsch

Open your Packages directory. Then edit this line https://github.com/daveleroy/sublime_debugger/blob/master/modules/adapters/util/lsp.py#L25 in the Debugger package. Then restart ST.

LDAP avatar Feb 09 '23 10:02 LDAP