Mark Storer
Mark Storer

Reputation: 15868

IntelliJ 2019.2.2: Unable to debug gradle unit tests

Every time I try to debug one of my tests (junit 5), I get an exception:

2019-12-20 10:40:53,776 [4972237]   WARN - .ExternalSystemTaskDebugRunner - Interrupted function call: accept failed
java.net.SocketException: Interrupted function call: accept failed
        at java.base/java.net.PlainSocketImpl.accept0(Native Method)
        at java.base/java.net.PlainSocketImpl.socketAccept(PlainSocketImpl.java:159)
        at java.base/java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:458)
        at java.base/java.net.ServerSocket.implAccept(ServerSocket.java:551)
        at java.base/java.net.ServerSocket.accept(ServerSocket.java:519)
        at com.intellij.openapi.externalSystem.service.execution.ForkedDebuggerThread.run(ForkedDebuggerThread.java:103)

I've done quite a bit of searching through SO here, and have found several people that had similar problems. Most of them were resolve simply by upgrading (to 2013 or whatever, these questions aren't exactly spring chickens). The rest required some special sauce relevant to their system (android stuff mostly). Or they're getting a different exception (being disconnected, where I'm never getting the connection in the first place).

These tests (unit tests for the most part) are attached to a module with no "main".

I've tried launching gradlew -DtestDebug.test=true cleanTest test, and then connect with a remote debug session. I get an error: Unable to open debugger port (localhost:5005); java.net.ConnectException "Connection refused: connect", which I believe is just what IntelliJ's gui shows when it receives the aforementioned exception.

Ideally, I'd like to set my breakpoints, debug-launch my test task (perhaps specifying a class or individual @Test), and it'd Just Work.

Does anyone have any other ideas I could try? Logs I could look at?

Upvotes: 3

Views: 2526

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 401897

The workaround is to switch the build/run actions to IntelliJ IDEA instead of using Gradle.

But if you still have this issue in the current IDE version, please consider reporting it with the sample project and the logs (Help | Compress Logs and Show in ...) attached.

Upvotes: 3

Related Questions