Log when test starts

This is helpful to see what logs belong to what test
This commit is contained in:
Nikolay Martynov 2019-02-11 12:19:18 -05:00
parent f33600d1f2
commit 05731c3c45
1 changed files with 8 additions and 3 deletions

View File

@ -24,6 +24,7 @@ import java.util.ServiceLoader;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.agent.ByteBuddyAgent; import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.agent.builder.AgentBuilder; import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
@ -54,6 +55,7 @@ import spock.lang.Specification;
*/ */
@RunWith(SpockRunner.class) @RunWith(SpockRunner.class)
@SpecMetadata(filename = "AgentTestRunner.java", line = 0) @SpecMetadata(filename = "AgentTestRunner.java", line = 0)
@Slf4j
public abstract class AgentTestRunner extends Specification { public abstract class AgentTestRunner extends Specification {
/** /**
* For test runs, agent's global tracer will report to this list writer. * For test runs, agent's global tracer will report to this list writer.
@ -114,9 +116,11 @@ public abstract class AgentTestRunner extends Specification {
final JavaModule module, final JavaModule module,
final boolean loaded, final boolean loaded,
final Throwable throwable) { final Throwable throwable) {
System.err.println( log.error(
"Unexpected instrumentation error when instrumenting " + typeName + " on " + classLoader); "Unexpected instrumentation error when instrumenting {} on {}",
throwable.printStackTrace(); typeName,
classLoader,
throwable);
return true; return true;
} }
@ -162,6 +166,7 @@ public abstract class AgentTestRunner extends Specification {
public void beforeTest() { public void beforeTest() {
assert getTestTracer().activeSpan() == null assert getTestTracer().activeSpan() == null
: "Span is active before test has started: " + getTestTracer().activeSpan(); : "Span is active before test has started: " + getTestTracer().activeSpan();
log.debug("Starting test: '{}'", getSpecificationContext().getCurrentIteration().getName());
TEST_WRITER.start(); TEST_WRITER.start();
} }