package io.atomix.atomix.testing;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.LoggerFactory;
import org.testng.IClass;
import org.testng.IInvokedMethod;
import org.testng.IInvokedMethodListener;
import org.testng.ITestNGMethod;
import org.testng.ITestResult;

public class TestCaseLogger implements IInvokedMethodListener {
  private static final Map<ITestNGMethod, Long> START_TIMES = new ConcurrentHashMap<>();

  public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
    if (!method.isTestMethod())
      return;

    ITestNGMethod testMethod = method.getTestMethod();
    IClass clazz = testMethod.getTestClass();

    START_TIMES.put(testMethod, System.currentTimeMillis());
    LoggerFactory.getLogger("BEFORE").info("{}.{}", clazz.getRealClass().getName(), testMethod.getMethodName());
  }

  public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
    if (!method.isTestMethod())
      return;

    ITestNGMethod testMethod = method.getTestMethod();
    IClass clazz = testMethod.getTestClass();
    double elapsed = (System.currentTimeMillis() - START_TIMES.remove(testMethod)) / 1000.0;

    if (elapsed > 1)
      LoggerFactory.getLogger("AFTER").info("{}.{} Ran for {} seconds", clazz.getRealClass().getName(),
          testMethod.getMethodName(), elapsed);
  }
}
@@ -787,17 +787,17 @@
 info(%22%7B%7D
-.
+#
 %7B%7D%22, cla
@@ -1248,17 +1248,17 @@
 info(%22%7B%7D
-.
+#
 %7B%7D Ran f

Use surefire compatible test case/method logging.