package io.github.mfulton26.ctrl4testng;

import com.google.common.base.MoreObjects;
import org.slf4j.Logger;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;

/**
 * Logger category format: [method-name]{[method-parameters]} on [class-name]{[class-parameters]} in [xml-suite-name]
 * Example output:
 * <pre>
 *     10:45:12.258 [main] INFO  log{} on DataDrivenClass{message=message 1} in ctrl4testng - message 1
 *     10:45:12.263 [main] INFO  log{} on DataDrivenClass{message=message 2} in ctrl4testng - message 2
 *     10:45:12.266 [main] INFO  info{message 1} on DataDrivenMethod{} in ctrl4testng - message 1
 *     10:45:12.266 [main] INFO  info{message 2} on DataDrivenMethod{} in ctrl4testng - message 2
 *     10:45:12.269 [main] ERROR error{} on Simple{} in ctrl4testng - this is an error log message
 *     10:45:12.270 [main] INFO  info{} on Simple{} in ctrl4testng - this is an informational log message
 *     10:45:12.272 [main] WARN  warn{} on Simple{} in ctrl4testng - this is a warning log message
 * </pre>
 *
 * @author Mark Fulton
 */
public class CurrentTestResultLoggerExampleTest {

    private static final Logger LOGGER = CurrentTestResultLoggerFactory.getLogger();

    public static class Simple {

        @Test
        public void info() {
            LOGGER.info("this is an informational log message");
        }

        @Test
        public void warn() {
            LOGGER.warn("this is a warning log message");
        }

        @Test
        public void error() {
            LOGGER.error("this is an error log message");
        }

    }

    public static abstract class DataDriven {

        @DataProvider
        public static Object[][] messages() {
            return new Object[][]{
                { "message 1" },
                { "message 2" }
            };
        }

    }

    public static class DataDrivenMethod extends DataDriven {

        @Test(dataProvider = "messages")
        public void info(String message) {
            LOGGER.info(message);
        }

    }

    public static class DataDrivenClass extends DataDriven {

        private final String message;

        @Factory(dataProvider = "messages")
        public DataDrivenClass(String message) {
            this.message = message;
        }

        @Test
        public void log() {
            LOGGER.info(message);
        }

        @Override
        public String toString() {
            return MoreObjects.toStringHelper(this)
                .add("message", message)
                .toString();
        }

    }

}

@@ -99,24 +99,66 @@
 f4j.Logger;%0A
+import org.testng.annotations.AfterClass;%0A
 import org.t
@@ -185,24 +185,24 @@
 taProvider;%0A
-
 import org.t
@@ -427,19 +427,19 @@
    1
-0:45:12.258
+1:11:09.335
  %5Bma
@@ -531,19 +531,19 @@
    1
-0:45:12.263
+1:11:09.339
  %5Bma
@@ -627,35 +627,35 @@
 e 2%0A *     1
-0:45:12.266
+1:11:09.342
  %5Bmain%5D INFO
@@ -733,19 +733,19 @@
    1
-0:45:12.266
+1:11:09.342
  %5Bma
@@ -831,19 +831,19 @@
    1
-0:45:12.269
+1:11:09.344
  %5Bma
@@ -930,19 +930,19 @@
    1
-0:45:12.270
+1:11:09.346
  %5Bma
@@ -1036,19 +1036,19 @@
    1
-0:45:12.272
+1:11:09.347
  %5Bma
@@ -1123,16 +1123,133 @@
 message%0A
+ *     11:11:09.349 %5Bmain%5D INFO  tearDownMethod%7B%7D on Simple%7B%7D in ctrl4testng - supports before and after methods too%0A
  * %3C/pre
@@ -1722,24 +1722,24 @@
 d error() %7B%0A
-
             
@@ -1787,32 +1787,168 @@
 e%22);%0A        %7D%0A%0A
+        @AfterClass%0A        public void tearDownMethod() %7B%0A            LOGGER.info(%22supports before and after methods too%22);%0A        %7D%0A%0A
     %7D%0A%0A    publi

Add before/after method to example