StringPrinter.java

1
package fr.sii.ogham.testing.extension.common;
2
3
import java.io.PrintWriter;
4
import java.io.StringWriter;
5
6
/**
7
 * Simple logger that writes header, success and failure using a
8
 * {@link StringWriter}. The {@link StringWriter} is passed to the constructor
9
 * to ba able to read the written strings from the external.
10
 * 
11
 * <p>
12
 * This is mainly used for tests
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class StringPrinter implements Printer {
18
	private final StringWriter writer;
19
	private final boolean writeMarker;
20
21
	/**
22
	 * 
23
	 * @param writer
24
	 *            the writer that can be shared
25
	 * @param writeMarker
26
	 *            true to write marker
27
	 */
28
	public StringPrinter(StringWriter writer, boolean writeMarker) {
29
		super();
30
		this.writer = writer;
31
		this.writeMarker = writeMarker;
32
	}
33
34
	@Override
35
	public void printHeader(String marker, String header) {
36 2 1. printHeader : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE
2. printHeader : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED
		printMarker(marker);
37
		writer.append(header + "\n\n");
38
	}
39
40
	@Override
41
	public void printSucess(String marker, String success) {
42 2 1. printSucess : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED
2. printSucess : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE
		printMarker(marker);
43
		writer.append(success + "\n\n");
44
	}
45
46
	@Override
47
	public void printFailure(String marker, String failure, Throwable e) {
48 2 1. printFailure : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED
2. printFailure : removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE
		printMarker(marker);
49
		writer.append("Test failure:" + e + "\n");
50 2 1. printFailure : removed call to java/lang/Throwable::printStackTrace → NO_COVERAGE
2. printFailure : removed call to java/lang/Throwable::printStackTrace → SURVIVED
		e.printStackTrace(new PrintWriter(writer));
51
		writer.append(failure + "\n\n");
52
	}
53
54
55
	private void printMarker(String marker) {
56 2 1. printMarker : negated conditional → NO_COVERAGE
2. printMarker : negated conditional → SURVIVED
		if (writeMarker) {
57
			writer.append("[marker:" + marker + "]\n");
58
		}
59
	}
60
}

Mutations

36

1.1
Location : printHeader
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE

2.2
Location : printHeader
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED

42

1.1
Location : printSucess
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED

2.2
Location : printSucess
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE

48

1.1
Location : printFailure
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → SURVIVED

2.2
Location : printFailure
Killed by : none
removed call to fr/sii/ogham/testing/extension/common/StringPrinter::printMarker → NO_COVERAGE

50

1.1
Location : printFailure
Killed by : none
removed call to java/lang/Throwable::printStackTrace → NO_COVERAGE

2.2
Location : printFailure
Killed by : none
removed call to java/lang/Throwable::printStackTrace → SURVIVED

56

1.1
Location : printMarker
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : printMarker
Killed by : none
negated conditional → SURVIVED

Active mutators

Tests examined


Report generated by PIT OGHAM