LoggingTestInterceptor.java

1
package fr.sii.ogham.testing.extension.spock;
2
3
import org.spockframework.runtime.extension.IMethodInterceptor;
4
import org.spockframework.runtime.extension.IMethodInvocation;
5
6
import fr.sii.ogham.testing.extension.common.LogTestInformation;
7
import fr.sii.ogham.testing.extension.common.TestInformationLogger;
8
9
/**
10
 * Interceptor to write information about test in logs.
11
 * 
12
 * @author Aurélien Baudet
13
 *
14
 */
15
public class LoggingTestInterceptor implements IMethodInterceptor {
16
	private final TestInformationLogger logger;
17
18
	public LoggingTestInterceptor(LogTestInformation annotation) throws InstantiationException, IllegalAccessException {
19
		this(new TestInformationLogger(annotation.maxLength(), annotation.marker(), annotation.printer().newInstance()));
20
	}
21
22
	public LoggingTestInterceptor(TestInformationLogger logger) {
23
		super();
24
		this.logger = logger;
25
	}
26
27
	@Override
28
	public void intercept(IMethodInvocation invocation) throws Throwable {
29
		String testName = invocation.getIteration().getDisplayName();
30
		try {
31 1 1. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → RUN_ERROR
			logger.writeStart(testName);
32 1 1. intercept : removed call to org/spockframework/runtime/extension/IMethodInvocation::proceed → RUN_ERROR
			invocation.proceed();
33 1 1. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeSuccess → RUN_ERROR
			logger.writeSuccess(testName);
34
		} catch (Throwable e) { // NOSONAR
35 1 1. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeFailure → NO_COVERAGE
			logger.writeFailure(testName, e);
36
			throw e;
37
		}
38
	}
39
40
}

Mutations

31

1.1
Location : intercept
Killed by :
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → RUN_ERROR

32

1.1
Location : intercept
Killed by :
removed call to org/spockframework/runtime/extension/IMethodInvocation::proceed → RUN_ERROR

33

1.1
Location : intercept
Killed by :
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeSuccess → RUN_ERROR

35

1.1
Location : intercept
Killed by :
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeFailure → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1