Add test method information to log output

Often it's hard to tell which testmethods were already executed
when a particualr test fails. This commit adds a log output when a
new test is started to better differentiate which log output belongs
to which test.

This commit also moves the reproduce line to logging output to gain
timestamps for the failure.
This commit is contained in:
Simon Willnauer 2013-08-15 13:16:13 +02:00
parent 43fcc55625
commit 1e7c0d69ff
1 changed files with 11 additions and 2 deletions

View File

@ -3,6 +3,9 @@ package org.elasticsearch.junit.listerners;
import com.carrotsearch.randomizedtesting.RandomizedContext;
import com.carrotsearch.randomizedtesting.ReproduceErrorMessageBuilder;
import com.carrotsearch.randomizedtesting.TraceFormatting;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.integration.ElasticsearchTestCase;
import org.junit.internal.AssumptionViolatedException;
import org.junit.runner.Description;
import org.junit.runner.notification.Failure;
@ -14,6 +17,12 @@ import org.junit.runner.notification.RunListener;
*/
public class ReproduceInfoPrinter extends RunListener {
protected final ESLogger logger = Loggers.getLogger(ElasticsearchTestCase.class);
@Override
public void testStarted(Description description) throws Exception {
logger.info("Test {} started", description.getDisplayName());
}
@Override
public void testFailure(Failure failure) throws Exception {
@ -39,7 +48,7 @@ public class ReproduceInfoPrinter extends RunListener {
}
traces.formatThrowable(b, failure.getException());
}
System.out.println(b.toString());
logger.error(b.toString());
}
private static class MavenMessageBuilder extends ReproduceErrorMessageBuilder {