test timed out after <N> milliseconds – JUnit 5 @Timeout does not interrupt test thread
0 reputation · 15 Apr 2020, 17:06 UTC
The goal is to guarantee that a test method that exceeds its @Timeout limit has its executing thread interrupted, preventing any lingering side‑effects such as resource leaks or inconsistent state.
Currently, JUnit 5’s TimeoutExtension records a failure but does not call Thread.interrupt() on the test thread, leaving the thread to continue running after the test method returns. Whether this behavior should change is an open design decision within the JUnit 5 project.
Should JUnit 5 @Timeout interrupt the test thread on timeout? What risks or benefits would automatic thread introduction pose for existing test suites and extensions? How would such a change affect cleanup code in finally blocks or custom extensions?