@Override
  public void testFailure(Failure failure) throws Exception {
    if (
      failure != null && failure.getMessage() != null
        && failure.getMessage().startsWith(TEST_TIMED_OUT_PREFIX)
    ) {
      output.println("====> TEST TIMED OUT. PRINTING THREAD DUMP. <====");
      output.println();
      output.print(buildThreadDiagnosticString());
    }
    output.flush();
  }
JUnit run listener which prints full thread dump into System.err in case a test is failed due to
timeout.
hbase-common/src/test/java/org/apache/hadoop/hbase/TimedOutTestsListener.java