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().getName();
30
		try {
31 2 1. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → SURVIVED
2. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → NO_COVERAGE
			logger.writeStart(testName);
32 2 1. intercept : removed call to org/spockframework/runtime/extension/IMethodInvocation::proceed → SURVIVED
2. intercept : removed call to org/spockframework/runtime/extension/IMethodInvocation::proceed → NO_COVERAGE
			invocation.proceed();
33 2 1. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeSuccess → SURVIVED
2. intercept : removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeSuccess → NO_COVERAGE
			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 : none
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → SURVIVED

2.2
Location : intercept
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeStart → NO_COVERAGE

32

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

2.2
Location : intercept
Killed by : none
removed call to org/spockframework/runtime/extension/IMethodInvocation::proceed → NO_COVERAGE

33

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

2.2
Location : intercept
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/TestInformationLogger::writeSuccess → NO_COVERAGE

35

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

Active mutators

Tests examined


Report generated by PIT OGHAM