@Override
    public int getVal(Phase phase) {
      Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
      if (phase == Phase.INITIAL) {
        stringsToLog = null;
        for (Thread t : stackTraces.keySet()) {
          initialThreadNames.add(t.getName());
        }
      } else if (phase == Phase.END) {
        if (stackTraces.size() > initialThreadNames.size()) {
          stringsToLog = new ArrayList<>();
          for (Thread t : stackTraces.keySet()) {
            if (!initialThreadNames.contains(t.getName())) {
              stringsToLog.add("\nPotentially hanging thread: " + t.getName() + "\n");
              StackTraceElement[] stackElements = stackTraces.get(t);
              for (StackTraceElement ele : stackElements) {
                stringsToLog.add("\t" + ele + "\n");
              }
            }
          }
        }
      }
      return stackTraces.size();
    }
Listen to the test progress and check the usage of:
<ul>
<li>threads</li>
<li>open file descriptor</li>
<li>max open file descriptor</li>
</ul>
<p>
When surefire forkMode=once/always/perthread, this code is executed on the forked process.
hbase-common/src/test/java/org/apache/hadoop/hbase/ResourceCheckerJUnitListener.java