From 5c54f5d9dd4cebe1e2384c8b77ce3c8d89a2ce19 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 17:26:37 +0100 Subject: [PATCH 1/7] Add a JUnit parser. --- .github/release-drafter.yml | 2 +- .../edu/hm/hafner/coverage/ClassNode.java | 57 +++++ .../java/edu/hm/hafner/coverage/Metric.java | 9 +- .../java/edu/hm/hafner/coverage/TestCase.java | 180 +++++++++++++++ .../edu/hm/hafner/coverage/TestCount.java | 25 ++ .../hafner/coverage/parser/JunitParser.java | 151 ++++++++++++ .../edu/hm/hafner/coverage/CoverageTest.java | 2 +- .../coverage/CyclomaticComplexityTest.java | 2 +- .../hm/hafner/coverage/FractionValueTest.java | 2 +- .../hm/hafner/coverage/LinesOfCodeTest.java | 2 +- .../edu/hm/hafner/coverage/MetricTest.java | 4 +- .../java/edu/hm/hafner/coverage/NodeTest.java | 2 +- .../hm/hafner/coverage/PackageNodeTest.java | 4 +- .../hm/hafner/coverage/SafeFractionTest.java | 2 +- .../coverage/parser/AbstractParserTest.java | 13 +- .../coverage/parser/CoberturaParserTest.java | 5 + .../coverage/parser/JacocoParserTest.java | 5 + .../coverage/parser/JunitParserTest.java | 216 ++++++++++++++++++ .../coverage/parser/PitestParserTest.java | 5 + .../cobertura-absolute-path.xml | 0 .../cobertura-counter-aggregation.xml | 0 .../cobertura-duplicate-classes.xml | 0 .../cobertura-duplicate-methods.xml | 0 .../cobertura-lots-of-data.xml | 0 .../{ => cobertura}/cobertura-merge-a.xml | 0 .../{ => cobertura}/cobertura-merge-b.xml | 0 .../cobertura-missing-condition-coverage.xml | 0 .../parser/{ => cobertura}/cobertura-npe.xml | 0 .../{ => cobertura}/cobertura-python.xml | 0 .../{ => cobertura}/cobertura-small.xml | 0 .../parser/{ => cobertura}/cobertura-ts.xml | 0 .../parser/{ => cobertura}/cobertura.xml | 0 .../coverage-missing-sources.xml | 0 .../parser/{ => jacoco}/file-subpackage.xml | 0 .../{ => jacoco}/jacoco-analysis-model.xml | 0 .../parser/{ => jacoco}/jacoco-big.xml | 0 .../jacoco-codingstyle-no-sourcefilename.xml | 0 .../{ => jacoco}/jacoco-codingstyle.xml | 0 .../parser/{ => jacoco}/jacoco-merge-a.xml | 0 .../parser/{ => jacoco}/jacoco-merge-b.xml | 0 .../parser/{ => jacoco}/jacoco-merge-c.xml | 0 .../parser/{ => jacoco}/jacocoTestReport.xml | 0 .../coverage/parser/junit/JENKINS-64117.xml | 203 ++++++++++++++++ ...ugins.jvctb.perform.JvctbPerformerTest.xml | 90 ++++++++ .../parser/junit/TESTS-TestSuites.xml | 49 ++++ .../coverage/parser/junit/archunit1.xml | 17 ++ .../coverage/parser/junit/archunit2.xml | 24 ++ .../hafner/coverage/parser/junit/cfn-lint.xml | 187 +++++++++++++++ .../coverage/parser/junit/issue-113.xml | 86 +++++++ .../coverage/parser/junit/jest-junit.xml | 52 +++++ .../parser/junit/junit-no-message-or-type.xml | 10 + .../hm/hafner/coverage/parser/junit/junit.xml | 118 ++++++++++ .../hafner/coverage/parser/junit/junit2.xml | 51 +++++ .../coverage/parser/junit/plainerror.xml | 4 + .../junit/without-message-with-type.xml | 72 ++++++ .../mutation-with-blocks-and-indexes.xml | 0 .../coverage/parser/{ => pit}/mutation.xml | 0 .../{ => pit}/mutations-codingstyle.xml | 0 .../coverage/parser/{ => pit}/mutations.xml | 0 59 files changed, 1635 insertions(+), 16 deletions(-) create mode 100644 src/main/java/edu/hm/hafner/coverage/TestCase.java create mode 100644 src/main/java/edu/hm/hafner/coverage/TestCount.java create mode 100644 src/main/java/edu/hm/hafner/coverage/parser/JunitParser.java create mode 100644 src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-absolute-path.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-counter-aggregation.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-duplicate-classes.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-duplicate-methods.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-lots-of-data.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-merge-a.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-merge-b.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-missing-condition-coverage.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-npe.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-python.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-small.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura-ts.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/cobertura.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => cobertura}/coverage-missing-sources.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/file-subpackage.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-analysis-model.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-big.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-codingstyle-no-sourcefilename.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-codingstyle.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-merge-a.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-merge-b.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacoco-merge-c.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => jacoco}/jacocoTestReport.xml (100%) create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/JENKINS-64117.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/TEST-org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/TESTS-TestSuites.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit1.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit2.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/cfn-lint.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/issue-113.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/jest-junit.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/junit-no-message-or-type.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/junit.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/junit2.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/plainerror.xml create mode 100644 src/test/resources/edu/hm/hafner/coverage/parser/junit/without-message-with-type.xml rename src/test/resources/edu/hm/hafner/coverage/parser/{ => pit}/mutation-with-blocks-and-indexes.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => pit}/mutation.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => pit}/mutations-codingstyle.xml (100%) rename src/test/resources/edu/hm/hafner/coverage/parser/{ => pit}/mutations.xml (100%) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index b3371837..7f99f6ce 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -20,7 +20,7 @@ categories: label: dependencies - title: 🔧 Internal Changes label: internal - - title: 🚦 Tests + - title: 🚦 TestCount label: tests version-resolver: diff --git a/src/main/java/edu/hm/hafner/coverage/ClassNode.java b/src/main/java/edu/hm/hafner/coverage/ClassNode.java index 8286e60a..21e6721f 100644 --- a/src/main/java/edu/hm/hafner/coverage/ClassNode.java +++ b/src/main/java/edu/hm/hafner/coverage/ClassNode.java @@ -1,11 +1,16 @@ package edu.hm.hafner.coverage; +import java.util.ArrayList; +import java.util.List; + /** * A {@link Node} for a specific class. */ public final class ClassNode extends Node { private static final long serialVersionUID = 1621410859864978552L; + private List testCases = new ArrayList<>(); + /** * Creates a new {@link ClassNode} with the given name. * @@ -21,6 +26,18 @@ public ClassNode copy() { return new ClassNode(getName()); } + /** + * Called after deserialization to retain backward compatibility. + * + * @return this + */ + private Object readResolve() { + if (testCases == null) { + testCases = new ArrayList<>(); + } + return this; + } + /** * Create a new method node with the given method name and signature and add it to the list of children. * @@ -41,4 +58,44 @@ public MethodNode createMethodNode(final String methodName, final String signatu public boolean isAggregation() { return false; } + + /** + * Adds a new test case to this class. + * + * @param testCase + * the test case to add + */ + public void addTestCase(final TestCase testCase) { + testCases.add(testCase); + + replaceValue(new TestCount(testCases.size())); + } + + public List getTestCases() { + return testCases; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + + ClassNode classNode = (ClassNode) o; + + return testCases.equals(classNode.testCases); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + testCases.hashCode(); + return result; + } } diff --git a/src/main/java/edu/hm/hafner/coverage/Metric.java b/src/main/java/edu/hm/hafner/coverage/Metric.java index 00f958a6..cbd6732b 100644 --- a/src/main/java/edu/hm/hafner/coverage/Metric.java +++ b/src/main/java/edu/hm/hafner/coverage/Metric.java @@ -13,7 +13,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** - * A coverage metric to identify the coverage result type. Note the enum order since the ordinal is used to sort the + * A metric to identify the type of the results. The enum order will be used to sort the * values for display purposes. * * @author Ullrich Hafner @@ -37,7 +37,8 @@ public enum Metric { COMPLEXITY(new ValuesAggregator(), MetricTendency.SMALLER_IS_BETTER), COMPLEXITY_MAXIMUM(new MethodMaxComplexityFinder(), MetricTendency.SMALLER_IS_BETTER), COMPLEXITY_DENSITY(new DensityEvaluator(), MetricTendency.SMALLER_IS_BETTER), - LOC(new LocEvaluator(), MetricTendency.SMALLER_IS_BETTER); + LOC(new LocEvaluator(), MetricTendency.SMALLER_IS_BETTER), + TESTS(new ValuesAggregator(), MetricTendency.LARGER_IS_BETTER); /** * Returns the metric that belongs to the specified tag. @@ -218,10 +219,10 @@ public boolean isAggregatingChildren() { @Override Optional compute(final Node node, final Metric searchMetric) { - if (node.getMetric() == Metric.METHOD) { + if (node.getMetric() == METHOD) { return COMPLEXITY.getValueFor(node) .map(c -> new CyclomaticComplexity(((CyclomaticComplexity)c).getValue(), - Metric.COMPLEXITY_MAXIMUM)); + COMPLEXITY_MAXIMUM)); } return node.getChildren().stream() .map(c -> compute(c, searchMetric)) diff --git a/src/main/java/edu/hm/hafner/coverage/TestCase.java b/src/main/java/edu/hm/hafner/coverage/TestCase.java new file mode 100644 index 00000000..935d0f75 --- /dev/null +++ b/src/main/java/edu/hm/hafner/coverage/TestCase.java @@ -0,0 +1,180 @@ +package edu.hm.hafner.coverage; + +import java.io.Serializable; + +import org.apache.commons.lang3.StringUtils; + +import com.google.errorprone.annotations.CanIgnoreReturnValue; + +/** + * Class which represents a test case. + * + * @author Ullrich Hafner + */ +public final class TestCase implements Serializable { + private static final long serialVersionUID = -2181204291759959155L; + + private final String testName; + private final String className; + private final TestResult status; + private final String type; + private final String message; + private final String description; + + private TestCase(final String testName, final String className, final TestResult status, + final String type, final String message, final String description) { + this.testName = testName; + this.className = className.intern(); + this.status = status; + this.type = type; + this.message = message; + this.description = description; + } + + public String getTestName() { + return testName; + } + + public String getClassName() { + return className; + } + + public TestResult getStatus() { + return status; + } + + public String getType() { + return type; + } + + public String getMessage() { + return message; + } + + public String getDescription() { + return description; + } + + @Override + public boolean equals(final Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + TestCase testCase = (TestCase) o; + + if (!testName.equals(testCase.testName)) { + return false; + } + if (!className.equals(testCase.className)) { + return false; + } + if (status != testCase.status) { + return false; + } + if (!type.equals(testCase.type)) { + return false; + } + if (!message.equals(testCase.message)) { + return false; + } + return description.equals(testCase.description); + } + + @Override + public String toString() { + return "TestCase{testName='" + testName + '\'' + ", className='" + className + '\'' + ", status=" + status + + ", type='" + type + '\'' + ", message='" + message + '\'' + ", description='" + description + '\'' + + '}'; + } + + @Override + public int hashCode() { + int result = testName.hashCode(); + result = 31 * result + className.hashCode(); + result = 31 * result + status.hashCode(); + result = 31 * result + type.hashCode(); + result = 31 * result + message.hashCode(); + result = 31 * result + description.hashCode(); + return result; + } + + /** + * Builder to create new {@link TestCase} instances. + */ + @SuppressWarnings({"checkstyle:MissingJavadocMethod", "checkstyle:HiddenField", "ParameterHidesMemberVariable"}) + public static class TestCaseBuilder { + private TestResult status = TestResult.PASSED; + private String testName = StringUtils.EMPTY; + private String className = StringUtils.EMPTY; + private String type = StringUtils.EMPTY; + private String message = StringUtils.EMPTY; + private String description = StringUtils.EMPTY; + + @CanIgnoreReturnValue + public TestCaseBuilder withStatus(final TestResult status) { + this.status = status; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withTestName(final String testName) { + this.testName = testName; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withClassName(final String className) { + this.className = className; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withType(final String type) { + this.type = type; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withMessage(final String message) { + this.message = message; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withDescription(final String description) { + this.description = description; + + return this; + } + + @CanIgnoreReturnValue + public TestCaseBuilder withFailure() { + status = TestResult.FAILED; + + return this; + } + + public TestCase build() { + return new TestCase(testName, className, status, type, message, description); + } + } + + /** + * The result of a test case. + */ + public enum TestResult { + PASSED, + FAILED, + SKIPPED, + ABORTED + } +} diff --git a/src/main/java/edu/hm/hafner/coverage/TestCount.java b/src/main/java/edu/hm/hafner/coverage/TestCount.java new file mode 100644 index 00000000..33bfb188 --- /dev/null +++ b/src/main/java/edu/hm/hafner/coverage/TestCount.java @@ -0,0 +1,25 @@ +package edu.hm.hafner.coverage; + +/** + * Represents the total number of tests. + * + * @author Ullrich Hafner + */ +public final class TestCount extends IntegerValue { + private static final long serialVersionUID = -3098842770938054269L; + + /** + * Creates a new {@link TestCount} instance with the number of tests. + * + * @param tests + * the number of tests + */ + public TestCount(final int tests) { + super(Metric.TESTS, tests); + } + + @Override + protected IntegerValue create(final int value) { + return new TestCount(value); + } +} diff --git a/src/main/java/edu/hm/hafner/coverage/parser/JunitParser.java b/src/main/java/edu/hm/hafner/coverage/parser/JunitParser.java new file mode 100644 index 00000000..854c6c3a --- /dev/null +++ b/src/main/java/edu/hm/hafner/coverage/parser/JunitParser.java @@ -0,0 +1,151 @@ +package edu.hm.hafner.coverage.parser; + +import java.io.Reader; +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.UUID; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import edu.hm.hafner.coverage.CoverageParser; +import edu.hm.hafner.coverage.ModuleNode; +import edu.hm.hafner.coverage.TestCase; +import edu.hm.hafner.coverage.TestCase.TestCaseBuilder; +import edu.hm.hafner.util.FilteredLog; +import edu.hm.hafner.util.SecureXmlParserFactory; +import edu.hm.hafner.util.SecureXmlParserFactory.ParsingException; + +/** + * Parses reports in the JUnit format into a Java object model. + * + * @author Ullrich Hafner + */ +@SuppressWarnings("checkstyle:ClassDataAbstractionCoupling") +public class JunitParser extends CoverageParser { + private static final long serialVersionUID = -5468593789018138107L; + + private static final QName TEST_SUITE = new QName("testsuite"); + private static final QName TEST_CASE = new QName("testcase"); + private static final QName NAME = new QName("name"); + private static final QName CLASS_NAME = new QName("classname"); + private static final QName FAILURE = new QName("failure"); + private static final QName FAILURE_TYPE = new QName("type"); + private static final QName MESSAGE = new QName("message"); + private static final QName ERROR = new QName("error"); + private static final QName SKIPPED = new QName("skipped"); + private static final String EMPTY = "-"; + + @Override + protected ModuleNode parseReport(final Reader reader, final FilteredLog log) { + try { + var factory = new SecureXmlParserFactory(); + var eventReader = factory.createXmlEventReader(reader); + + var root = new ModuleNode(EMPTY); + var tests = readTestCases(eventReader, root); + if (tests.isEmpty()) { + throw new NoSuchElementException("No test cases found"); + } + return root; + } + catch (XMLStreamException exception) { + throw new ParsingException(exception); + } + } + + private List readTestCases(final XMLEventReader eventReader, + final ModuleNode root) throws XMLStreamException { + String suiteName = EMPTY; + var tests = new ArrayList<>(); + while (eventReader.hasNext()) { + XMLEvent event = eventReader.nextEvent(); + + if (event.isStartElement() && TEST_SUITE.equals(event.asStartElement().getName())) { + suiteName = getOptionalValueOf(event.asStartElement(), NAME).orElse(EMPTY); + } + else if (event.isStartElement() && TEST_CASE.equals(event.asStartElement().getName())) { + tests.add(readTestCase(eventReader, event.asStartElement(), suiteName, root)); + } + } + return tests; + } + + private TestCase readTestCase(final XMLEventReader reader, final StartElement testCaseElement, + final String suiteName, final ModuleNode root) + throws XMLStreamException { + var builder = new TestCaseBuilder(); + + builder.withTestName(getOptionalValueOf(testCaseElement, NAME).orElse(createId())); + + while (reader.hasNext()) { + XMLEvent event = reader.nextEvent(); + + if (event.isStartElement() && isFailure(event)) { + readFailure(reader, event.asStartElement(), builder); + } + else if (event.isStartElement() && SKIPPED.equals(event.asStartElement().getName())) { + builder.withStatus(TestCase.TestResult.SKIPPED); + } + else if (event.isEndElement() && TEST_CASE.equals(event.asEndElement().getName())) { + var className = getOptionalValueOf(testCaseElement, CLASS_NAME).orElse(suiteName); + builder.withClassName(className); + var packageName = createPackageForClass(className); + var packageNode = root.findOrCreatePackageNode(packageName); + var classNode = packageNode.findOrCreateClassNode(className); + classNode.addTestCase(builder.build()); + return builder.build(); + } + } + throw createEofException(); + } + + private boolean isFailure(final XMLEvent event) { + QName name; + if (event.isStartElement()) { + name = event.asStartElement().getName(); + } + else { + name = event.asEndElement().getName(); + } + + return FAILURE.equals(name) || ERROR.equals(name); + } + + private String createPackageForClass(final String className) { + int lastDot = className.lastIndexOf('.'); + if (lastDot > 0) { + return className.substring(0, lastDot); + } + return "-"; + } + + private void readFailure(final XMLEventReader reader, final StartElement startElement, + final TestCaseBuilder builder) + throws XMLStreamException { + builder.withFailure(); + + getOptionalValueOf(startElement, FAILURE_TYPE).ifPresent(builder::withType); + getOptionalValueOf(startElement, MESSAGE).ifPresent(builder::withMessage); + + var aggregatedContent = new StringBuilder(); + + while (true) { + XMLEvent event = reader.nextEvent(); + if (event.isCharacters()) { + aggregatedContent.append(event.asCharacters().getData()); + } + else if (event.isEndElement() && isFailure(event)) { + builder.withDescription(aggregatedContent.toString()); + return; + } + } + } + + private String createId() { + return UUID.randomUUID().toString(); + } +} diff --git a/src/test/java/edu/hm/hafner/coverage/CoverageTest.java b/src/test/java/edu/hm/hafner/coverage/CoverageTest.java index 80e87aac..9e265160 100644 --- a/src/test/java/edu/hm/hafner/coverage/CoverageTest.java +++ b/src/test/java/edu/hm/hafner/coverage/CoverageTest.java @@ -15,7 +15,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link Coverage}. + * TestCount the class {@link Coverage}. * * @author Ullrich Hafner * @author Jannik Treichel diff --git a/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java b/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java index a5613ae7..27ffeb05 100644 --- a/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java +++ b/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java @@ -9,7 +9,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link CyclomaticComplexity}. + * TestCount the class {@link CyclomaticComplexity}. * * @author Melissa Bauer */ diff --git a/src/test/java/edu/hm/hafner/coverage/FractionValueTest.java b/src/test/java/edu/hm/hafner/coverage/FractionValueTest.java index fb7eda12..cde74993 100644 --- a/src/test/java/edu/hm/hafner/coverage/FractionValueTest.java +++ b/src/test/java/edu/hm/hafner/coverage/FractionValueTest.java @@ -8,7 +8,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link FractionValue}. + * TestCount the class {@link FractionValue}. * * @author Ullrich Hafner */ diff --git a/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java b/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java index 7df6e5ed..d54cd3be 100644 --- a/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java @@ -10,7 +10,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link CyclomaticComplexity}. + * TestCount the class {@link CyclomaticComplexity}. * * @author Melissa Bauer */ diff --git a/src/test/java/edu/hm/hafner/coverage/MetricTest.java b/src/test/java/edu/hm/hafner/coverage/MetricTest.java index 3fcdba5a..6529b968 100644 --- a/src/test/java/edu/hm/hafner/coverage/MetricTest.java +++ b/src/test/java/edu/hm/hafner/coverage/MetricTest.java @@ -10,7 +10,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link Metric}. + * TestCount the class {@link Metric}. * * @author Ullrich Hafner */ @@ -42,7 +42,7 @@ void shouldGetCoverageMetrics() { } /** - * Tests if the object in the evaluator-attribute of class {@link Metric} + * TestCount if the object in the evaluator-attribute of class {@link Metric} * correctly overrides its isAggregatingChildren-method. */ @Test diff --git a/src/test/java/edu/hm/hafner/coverage/NodeTest.java b/src/test/java/edu/hm/hafner/coverage/NodeTest.java index da0b8eff..59bde306 100644 --- a/src/test/java/edu/hm/hafner/coverage/NodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/NodeTest.java @@ -21,7 +21,7 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; /** - * Tests the class {@link Node}. + * TestCount the class {@link Node}. * * @author Ullrich Hafner */ diff --git a/src/test/java/edu/hm/hafner/coverage/PackageNodeTest.java b/src/test/java/edu/hm/hafner/coverage/PackageNodeTest.java index 5aca5650..b161f5a6 100644 --- a/src/test/java/edu/hm/hafner/coverage/PackageNodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/PackageNodeTest.java @@ -17,7 +17,7 @@ Node createNode(final String name) { } /** - * Tests the copy functionality with a child. + * TestCount the copy functionality with a child. */ @Test void shouldCopyEmpty() { @@ -36,7 +36,7 @@ void shouldCopyEmpty() { } /** - * Tests the match functionality using a path hashcode. + * TestCount the match functionality using a path hashcode. */ @Test void shouldMatchPath() { diff --git a/src/test/java/edu/hm/hafner/coverage/SafeFractionTest.java b/src/test/java/edu/hm/hafner/coverage/SafeFractionTest.java index ad82950e..795d0c79 100644 --- a/src/test/java/edu/hm/hafner/coverage/SafeFractionTest.java +++ b/src/test/java/edu/hm/hafner/coverage/SafeFractionTest.java @@ -6,7 +6,7 @@ import static org.assertj.core.api.Assertions.*; /** - * Tests the class {@link SafeFraction}. + * TestCount the class {@link SafeFraction}. * * @author Ullrich Hafner */ diff --git a/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java index c0cc9057..59e75f84 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java @@ -32,7 +32,7 @@ ModuleNode readReport(final String fileName) { } ModuleNode readReport(final String fileName, final CoverageParser parser) { - try (InputStream stream = AbstractParserTest.class.getResourceAsStream(fileName); + try (InputStream stream = createFile(fileName); Reader reader = new InputStreamReader(Objects.requireNonNull(stream), StandardCharsets.UTF_8)) { return parser.parse(reader, log); } @@ -41,6 +41,17 @@ ModuleNode readReport(final String fileName, final CoverageParser parser) { } } + @SuppressWarnings("resource") + private InputStream createFile(final String fileName) { + var file = AbstractParserTest.class.getResourceAsStream(fileName); + if (file == null) { + file = AbstractParserTest.class.getResourceAsStream(getFolder() + "/" + fileName); + } + return Objects.requireNonNull(file, "File not found: " + fileName); + } + + protected abstract String getFolder(); + abstract CoverageParser createParser(); protected FilteredLog getLog() { diff --git a/src/test/java/edu/hm/hafner/coverage/parser/CoberturaParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/CoberturaParserTest.java index 9c3ea1e5..0b5aba62 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/CoberturaParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/CoberturaParserTest.java @@ -36,6 +36,11 @@ CoberturaParser createParser() { return new CoberturaParser(); } + @Override + protected String getFolder() { + return "cobertura"; + } + @Test void shouldIgnoreMissingConditionAttribute() { Node missingCondition = readReport("cobertura-missing-condition-coverage.xml"); diff --git a/src/test/java/edu/hm/hafner/coverage/parser/JacocoParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/JacocoParserTest.java index 271d1e61..24d15446 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/JacocoParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/JacocoParserTest.java @@ -38,6 +38,11 @@ CoverageParser createParser() { return new JacocoParser(); } + @Override + protected String getFolder() { + return "jacoco"; + } + private static Coverage getCoverage(final Node node, final Metric metric) { return (Coverage) node.getValue(metric).get(); } diff --git a/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java new file mode 100644 index 00000000..2054a2c4 --- /dev/null +++ b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java @@ -0,0 +1,216 @@ +package edu.hm.hafner.coverage.parser; + +import java.util.Collection; +import java.util.NoSuchElementException; + +import org.junit.jupiter.api.Test; + +import edu.hm.hafner.coverage.ClassNode; +import edu.hm.hafner.coverage.CoverageParser; +import edu.hm.hafner.coverage.Metric; +import edu.hm.hafner.coverage.ModuleNode; +import edu.hm.hafner.coverage.Node; +import edu.hm.hafner.coverage.PackageNode; +import edu.hm.hafner.coverage.TestCase; +import edu.hm.hafner.coverage.TestCase.TestResult; +import edu.hm.hafner.coverage.TestCount; + +import static edu.hm.hafner.coverage.assertions.Assertions.*; + +class JunitParserTest extends AbstractParserTest { + private static final String EMPTY = "-"; + + @Override + CoverageParser createParser() { + return new JunitParser(); + } + + @Override + protected String getFolder() { + return "junit"; + } + + @Test + void shouldReadArchUnitTests() { + ModuleNode tree = readReport("archunit1.xml"); + + assertThat(tree.getAll(Metric.MODULE)).hasSize(1); + assertThat(tree.getAll(Metric.PACKAGE)).hasSize(1); + assertThat(tree.getAll(Metric.CLASS)).hasSize(1); + + assertThat(tree.aggregateValues()).contains(new TestCount(1)); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName(EMPTY); + + var testClass = getFirstClass(tree); + assertThat(testClass).hasName("Aufgabe3Test"); + assertThat(testClass.aggregateValues()).contains(new TestCount(1)); + assertThat(testClass.getTestCases()).hasSize(1); + + var testCase = getFirstTest(tree); + assertThat(testCase).hasStatus(TestResult.FAILED) + .hasClassName("Aufgabe3Test") + .hasTestName("shouldSplitToEmptyRight(int)[1]"); + assertThat(testCase.getMessage()).isEmpty(); + assertThat(testCase.getDescription()).contains( + "at Aufgabe3Test.shouldSplitToEmptyRight(Aufgabe3Test.java:254)"); + + ModuleNode node = readReport("archunit2.xml"); + + assertThat(node.getAll(Metric.CLASS)).hasSize(1); + assertThat(node.aggregateValues()).contains(new TestCount(3)); + } + + @Test + void shouldReadWithNameOnly() { + ModuleNode tree = readReport("cfn-lint.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName(EMPTY); + assertThat(getFirstClass(tree)).hasName("CloudFormation Lint"); + + assertThat(tree.aggregateValues()).contains(new TestCount(141)); + assertThat(tree.getAll(Metric.CLASS).stream() + .map(ClassNode.class::cast) + .map(ClassNode::getTestCases) + .flatMap(Collection::stream) + .filter(test -> test.getStatus() == TestResult.SKIPPED) + .count()).isEqualTo(19); + } + + @Test + void shouldReadFailure() { + ModuleNode tree = readReport("issue-113.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName(EMPTY); + assertThat(getFirstClass(tree)).hasName("Assignment1Test"); + assertThat(getFirstTest(tree).getDescription()).contains("Die Welten sind nicht korrekt"); + + assertThat(tree.aggregateValues()).contains(new TestCount(1)); + } + + @Test + void shouldReadError() { + ModuleNode tree = readReport("JENKINS-64117.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("eu.pinteam.kyoto.gunit.testenv.test"); + assertThat(getFirstClass(tree)).hasName("eu.pinteam.kyoto.gunit.testenv.test.CalculationUtilTest"); + assertThat(getFirstTest(tree).getMessage()).isEqualTo("The container NewcontTest0 does not allow a parameter of type f1"); + assertThat(getFirstTest(tree).getDescription()).contains("ava.lang.IllegalStateException: The container NewcontTest0 does not allow a parameter of type f1"); + + assertThat(tree.aggregateValues()).contains(new TestCount(3)); + } + + @Test + void shouldReadBrokenClassNames() { + ModuleNode tree = readReport("jest-junit.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName(EMPTY); + assertThat(getFirstClass(tree)).hasName("snapshots should display correct snapshot"); + assertThat(getFirstTest(tree).getDescription()).contains("Error: expect.assertions(3)"); + + assertThat(tree.aggregateValues()).contains(new TestCount(11)); + } + + @Test + void shouldReadJavaClassNames() { + ModuleNode tree = readReport("junit.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("com.example.jenkinstest"); + assertThat(getFirstClass(tree)).hasName("com.example.jenkinstest.ExampleUnitTest"); + assertThat(getFirstTest(tree).getDescription()).contains("com.example.jenkinstest.ExampleUnitTest.failTest4"); + + assertThat(tree.aggregateValues()).contains(new TestCount(6)); + } + + @Test + void shouldReadAndroidTestResults() { + ModuleNode tree = readReport("junit2.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("my.company"); + assertThat(getFirstClass(tree)).hasName("my.company.MainActivityTest"); + assertThat(getFirstTest(tree).getDescription()).contains("Looped for 3838 iterations over 60 SECONDS"); + + assertThat(tree.aggregateValues()).contains(new TestCount(1)); + } + + @Test + void shouldReadNoMessageAndType() { + ModuleNode tree = readReport("junit-no-message-or-type.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("timrAPITests"); + assertThat(getFirstClass(tree)).hasName("timrAPITests.UtilTests"); + assertThat(getFirstTest(tree).getDescription()).contains("timrAPITests/Tests/Utils/UtilTests.swift:23"); + + assertThat(tree.aggregateValues()).contains(new TestCount(3)); + } + + @Test + void shouldReadErrorWithoutSuite() { + ModuleNode tree = readReport("plainerror.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("edu.hm.hafner.analysis.parser"); + assertThat(getFirstClass(tree)).hasName("edu.hm.hafner.analysis.parser.SonarQubeDiffParserTest"); + assertThat(getFirstTest(tree).getDescription()).contains("org.json.JSONException: Missing value at 0"); + + assertThat(tree.aggregateValues()).contains(new TestCount(1)); + } + + @Test + void shouldReadPerformanceTestResults() { + ModuleNode tree = readReport("TEST-org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("org.jenkinsci.plugins.jvctb.perform"); + assertThat(getFirstClass(tree)).hasName("org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest"); + assertThat(getFirstTest(tree).getDescription()).contains("org.junit.ComparisonFailure"); + + assertThat(tree.aggregateValues()).contains(new TestCount(1)); + } + + @Test + void shouldReadTestSuites() { + ModuleNode tree = readReport("TESTS-TestSuites.xml"); + + assertThat(tree).hasName(EMPTY); + assertThat(getPackage(tree)).hasName("ch.bdna.tsm.service"); + assertThat(getFirstClass(tree)).hasName("ch.bdna.tsm.service.PollingServiceTest"); + assertThat(getFirstTest(tree).getDescription()).contains("Missing CPU value"); + + assertThat(tree.aggregateValues()).contains(new TestCount(2)); + } + + private PackageNode getPackage(final Node node) { + var children = node.getChildren(); + assertThat(children).hasSize(1).first().isInstanceOf(PackageNode.class); + + return (PackageNode) children.get(0); + } + + private ClassNode getFirstClass(final Node node) { + var packageNode = getPackage(node); + + var children = packageNode.getChildren(); + assertThat(children).isNotEmpty().first().isInstanceOf(ClassNode.class); + + return (ClassNode) children.get(0); + } + + private TestCase getFirstTest(final Node node) { + return node.getAll(Metric.CLASS).stream() + .map(ClassNode.class::cast) + .map(ClassNode::getTestCases) + .flatMap(Collection::stream) + .filter(test -> test.getStatus() == TestResult.FAILED) + .findFirst() + .orElseThrow(() -> new NoSuchElementException("No failed test found")); + } +} diff --git a/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java index 26272a0c..7879018e 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java @@ -25,6 +25,11 @@ CoverageParser createParser() { return new PitestParser(); } + @Override + protected String getFolder() { + return "pit"; + } + @Test void shouldReadAllMutationProperties() { ModuleNode tree = readReport("mutation.xml"); diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-absolute-path.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-absolute-path.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-absolute-path.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-absolute-path.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-counter-aggregation.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-counter-aggregation.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-counter-aggregation.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-counter-aggregation.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-duplicate-classes.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-duplicate-classes.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-duplicate-classes.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-duplicate-classes.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-duplicate-methods.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-duplicate-methods.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-duplicate-methods.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-duplicate-methods.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-lots-of-data.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-lots-of-data.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-lots-of-data.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-lots-of-data.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-merge-a.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-merge-a.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-merge-a.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-merge-a.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-merge-b.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-merge-b.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-merge-b.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-merge-b.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-missing-condition-coverage.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-missing-condition-coverage.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-missing-condition-coverage.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-missing-condition-coverage.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-npe.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-npe.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-npe.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-npe.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-python.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-python.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-python.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-python.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-small.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-small.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-small.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-small.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura-ts.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-ts.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura-ts.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura-ts.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/cobertura.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/cobertura.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/cobertura.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/coverage-missing-sources.xml b/src/test/resources/edu/hm/hafner/coverage/parser/cobertura/coverage-missing-sources.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/coverage-missing-sources.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/cobertura/coverage-missing-sources.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/file-subpackage.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/file-subpackage.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/file-subpackage.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/file-subpackage.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-analysis-model.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-analysis-model.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-analysis-model.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-analysis-model.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-big.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-big.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-big.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-big.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-codingstyle-no-sourcefilename.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-codingstyle-no-sourcefilename.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-codingstyle-no-sourcefilename.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-codingstyle-no-sourcefilename.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-codingstyle.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-codingstyle.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-codingstyle.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-codingstyle.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-a.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-a.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-a.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-a.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-b.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-b.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-b.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-b.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-c.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-c.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacoco-merge-c.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacoco-merge-c.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/jacocoTestReport.xml b/src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacocoTestReport.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/jacocoTestReport.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/jacoco/jacocoTestReport.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/JENKINS-64117.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/JENKINS-64117.xml new file mode 100644 index 00000000..63c69cf0 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/JENKINS-64117.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + java.lang.IllegalStateException: The container NewcontTest0 does not allow a parameter of type f1 + at eu.pinteam.kyoto.gunit.testenv.test.CalculationUtilTest.runCalculationScriptTest(CalculationUtilTest.java:188) + + (Converter.java:39) + at org.artop.aal.autosar40.converters.adapters.AbstractConverter40Adapter.getConverter(AbstractConverter40Adapter.java:34) + at org.artop.aal.converters.adapters.AbstractConverterAdapter.doConvertLoad(AbstractConverterAdapter.java:244) + at org.artop.aal.converters.adapters.AbstractConverterAdapter.convertLoad(AbstractConverterAdapter.java:162) + at org.eclipse.sphinx.emf.resource.ExtendedXMLLoadImpl.load(ExtendedXMLLoadImpl.java:106) + at org.artop.aal.common.resource.impl.AutosarXMLResourceImpl.doLoad(AutosarXMLResourceImpl.java:354) + at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1563) + at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1342) + at org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:1338) + at org.eclipse.sphinx.emf.util.EcoreResourceUtil.loadResource(EcoreResourceUtil.java:933) + at org.eclipse.sphinx.emf.util.EcorePlatformUtil$7.run(EcorePlatformUtil.java:723) + at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328) + at org.eclipse.emf.transaction.util.TransactionUtil.runExclusive(TransactionUtil.java:328) + at org.eclipse.sphinx.emf.util.EcorePlatformUtil.loadResource(EcorePlatformUtil.java:719) + at eu.pinteam.kyoto.gunit.testenv.utils.TestenvUtils.loadModuleConfiguration(TestenvUtils.java:518) + at eu.pinteam.kyoto.gunit.testenv.test.CalculationUtilTest.prepareTest(CalculationUtilTest.java:82) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) + at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) + at org.junit.runners.ParentRunner.run(ParentRunner.java:363) + at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365) + at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273) + at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238) + at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:206) + at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:161) + at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:84) + at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:113) + at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.run(HeadlessTestApplication.java:21) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:590) + at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:201) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) + at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391) + at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659) + at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595) + at org.eclipse.equinox.launcher.Main.run(Main.java:1501) + at org.eclipse.equinox.launcher.Main.main(Main.java:1474) +Caused by: java.io.IOException: Error while instrumenting org/artop/aal/autosar40/converters/BasicMigrator402. + at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrumentError(Instrumenter.java:159) + at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:109) + at org.jacoco.agent.rt.internal_43f5073.CoverageTransformer.transform(CoverageTransformer.java:92) + ... 73 more +Caused by: org.jacoco.agent.rt.internal_43f5073.asm.MethodTooLargeException: Method too large: org/artop/aal/autosar40/converters/BasicMigrator402.downgrade (Ljava/util/List;Lorg/artop/aal/converters/IReportGenerator;)V + at org.jacoco.agent.rt.internal_43f5073.asm.MethodWriter.computeMethodInfoSize(MethodWriter.java:2087) + at org.jacoco.agent.rt.internal_43f5073.asm.ClassWriter.toByteArray(ClassWriter.java:447) + at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:90) + at org.jacoco.agent.rt.internal_43f5073.core.instr.Instrumenter.instrument(Instrumenter.java:107) + ... 74 more +]]> + + + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/TEST-org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/TEST-org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.xml new file mode 100644 index 00000000..9a86b761 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/TEST-org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.junit.ComparisonFailure: expected:<["nondada"]> but was:<[ViolationsToBitbucketServerConfig [commentOnlyChangedContent=true, bitbucketServerUrl=AzQnMdHbDU, createCommentWithAllSingleFileComments=true, createSingleFileComments=true, projectKey=fBlSSDSlOP, pullRequestId=ZzGzSVGH4W, repoSlug=ENbvU4Oos4, credentialsId=dyqB_c1fLr, violationConfigs=[ViolationConfig [pattern=qq0LXu8hoh, reporter=gJEQ4QDunS, parser=CPPLINT], ViolationConfig [pattern=orreWzwVwM, reporter=C8UoEd21gb, parser=ANDROIDLINT], ViolationConfig [pattern=zhs6jSGj5i, reporter=8914z8cWV0, parser=DOCFX], ViolationConfig [pattern=r6uVRupZ4m, reporter=mnI8Q1TbZX, parser=KLOCWORK], ViolationConfig [pattern=gh1l1J71ut, reporter=vWjS10yxYz, parser=GOLINT]], commentOnlyChangedContentContext=1151454156, minSeverity=ERROR, keepOldComments=true]]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.testThatAllAttributesAreExpanded(JvctbPerformerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) + + org.junit.ComparisonFailure: expected:<["nondada"]> but was:<[ViolationsToBitbucketServerConfig [commentOnlyChangedContent=true, bitbucketServerUrl=s3B1OkUhmD, createCommentWithAllSingleFileComments=true, createSingleFileComments=true, projectKey=Zv9vbUGLQL, pullRequestId=xAfncocylB, repoSlug=13R1cFL4RC, credentialsId=cgqPPvJQFv, violationConfigs=[ViolationConfig [pattern=AVydcoN0QW, reporter=GjvDL6SmPy, parser=SONAR], ViolationConfig [pattern=FhilKJo97J, reporter=Eio5IiOXOs, parser=IAR], ViolationConfig [pattern=lpMUw4E3_m, reporter=tPt1nGLu7q, parser=SONAR], ViolationConfig [pattern=z3fl1Idvj1, reporter=7TTVRIbb6E, parser=LINT], ViolationConfig [pattern=G0Pv5RxJqi, reporter=B909AcGXXu, parser=SIMIAN]], commentOnlyChangedContentContext=-1496163006, minSeverity=ERROR, keepOldComments=true]]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.testThatAllAttributesAreExpanded(JvctbPerformerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:290) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) + + + org.junit.ComparisonFailure: expected:<["nondada"]> but was:<[ViolationsToBitbucketServerConfig [commentOnlyChangedContent=true, bitbucketServerUrl=nOApddS11B, createCommentWithAllSingleFileComments=true, createSingleFileComments=true, projectKey=tthlz72ncf, pullRequestId=sQfc3KTq7u, repoSlug=SOt08S7IIt, credentialsId=5LYSJ2FVoc, violationConfigs=[ViolationConfig [pattern=rqSgFoz1Pe, reporter=JudFQZgI0S, parser=SBTSCALAC], ViolationConfig [pattern=7flcgQnOw7, reporter=G2oQ2sD7KV, parser=CSSLINT], ViolationConfig [pattern=oNPl7YYcSA, reporter=Oypzz7Tp6J, parser=KLOCWORK], ViolationConfig [pattern=OyNUUeVj3L, reporter=TDBMi5t4NL, parser=CHECKSTYLE], ViolationConfig [pattern=VOcnOg8OGH, reporter=hhLw0qS2KX, parser=MSCPP]], commentOnlyChangedContentContext=-1594051247, minSeverity=WARN, keepOldComments=true]]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.testThatAllAttributesAreExpanded(JvctbPerformerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:290) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) + + + org.junit.ComparisonFailure: expected:<["nondada"]> but was:<[ViolationsToBitbucketServerConfig [commentOnlyChangedContent=true, bitbucketServerUrl=4QkVMi1DsI, createCommentWithAllSingleFileComments=true, createSingleFileComments=true, projectKey=eWlW7DEdFB, pullRequestId=ZqSbOdIBt2, repoSlug=P4gi7hjXv7, credentialsId=x5FSNkyewf, violationConfigs=[ViolationConfig [pattern=kVzNI716lM, reporter=diUSKu_x2c, parser=PERLCRITIC], ViolationConfig [pattern=tLP9yEsIn6, reporter=5_NSAxK30v, parser=PYDOCSTYLE], ViolationConfig [pattern=GQT2b918s5, reporter=qm1mWVgUf5, parser=STYLECOP], ViolationConfig [pattern=Un946Mqj_H, reporter=nuxX5WYwNH, parser=MYPY], ViolationConfig [pattern=m_RKTYdFMs, reporter=XakZgq3YdL, parser=FLAKE8]], commentOnlyChangedContentContext=1701481204, minSeverity=INFO, keepOldComments=true]]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.testThatAllAttributesAreExpanded(JvctbPerformerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:290) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) + + + org.junit.ComparisonFailure: expected:<["nondada"]> but was:<[ViolationsToBitbucketServerConfig [commentOnlyChangedContent=true, bitbucketServerUrl=IoKXOGYgsK, createCommentWithAllSingleFileComments=true, createSingleFileComments=true, projectKey=6o6wWwc0QH, pullRequestId=TwiFxk522h, repoSlug=Go26ghOAz6, credentialsId=IqL5x3B5CZ, violationConfigs=[ViolationConfig [pattern=gKfupLMdyS, reporter=rbs6Mnx4UV, parser=XMLLINT], ViolationConfig [pattern=Piw9YqQ1xY, reporter=VJ2lfVnFeX, parser=XMLLINT], ViolationConfig [pattern=KJiIJlaNIO, reporter=BORlcUBYBj, parser=STYLECOP], ViolationConfig [pattern=iTTyrS6AgV, reporter=dhxTfh67xN, parser=MYPY], ViolationConfig [pattern=HhPo32YQAr, reporter=aqwTkV6oes, parser=KOTLINGRADLE]], commentOnlyChangedContentContext=175813371, minSeverity=WARN, keepOldComments=true]]> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at org.jenkinsci.plugins.jvctb.perform.JvctbPerformerTest.testThatAllAttributesAreExpanded(JvctbPerformerTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.executeFailedMethod(JUnit4Provider.java:379) at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:290) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) + + + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/TESTS-TestSuites.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/TESTS-TestSuites.xml new file mode 100644 index 00000000..f44fa8d5 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/TESTS-TestSuites.xml @@ -0,0 +1,49 @@ + + + + + + + + junit.framework.AssertionFailedError: Missing CPU value + at ch.bdna.tsm.service.PollingServiceTest.testServices(PollingServiceTest.java:22) + + + + + + + + + + + + + + + + junit.framework.AssertionFailedError: expected:<1> but was:<7> + at ch.bdna.tsm.service.ResourceServiceTest.testService(ResourceServiceTest.java:40) + + + + + + + + + + diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit1.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit1.xml new file mode 100644 index 00000000..9a4f6297 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit1.xml @@ -0,0 +1,17 @@ + + + + +to be equal to: + <[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]]]> +when comparing elements using recursive field/property by field/property comparator on all fields/properties +Comparators used: +- for elements fields (by type): {Double -> DoubleComparator[precision=1.0E-15], Float -> FloatComparator[precision=1.0E-6]} +- for elements (by type): {Double -> DoubleComparator[precision=1.0E-15], Float -> FloatComparator[precision=1.0E-6]} +but was not. + at Aufgabe3Test.shouldSplitToEmptyRight(Aufgabe3Test.java:254) +]]> + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit2.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit2.xml new file mode 100644 index 00000000..3e9eb1d1 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/archunit2.xml @@ -0,0 +1,24 @@ + + + + +to be equal to: + <[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]]]> +when comparing elements using recursive field/property by field/property comparator on all fields/properties +Comparators used: +- for elements fields (by type): {Double -> DoubleComparator[precision=1.0E-15], Float -> FloatComparator[precision=1.0E-6]} +- for elements (by type): {Double -> DoubleComparator[precision=1.0E-15], Float -> FloatComparator[precision=1.0E-6]} +but was not. + at Aufgabe3Test.shouldSplitToEmptyRight(Aufgabe3Test.java:254) +]]> + + + + is not final in (Integers.java:0) +]]> + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/cfn-lint.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/cfn-lint.xml new file mode 100644 index 00000000..708a1bcf --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/cfn-lint.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/issue-113.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/issue-113.xml new file mode 100644 index 00000000..e547adc5 --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/issue-113.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + but was:< +Kara: [0, 0, RIGHT] + + + + + +> + at Assignment1Test.shouldDrawIBIntoEmptyWorld(Assignment1Test.java:14) +]]> + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/jest-junit.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/jest-junit.xml new file mode 100644 index 00000000..3708fb9d --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/jest-junit.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Error: expect(received).toBe(expected) // Object.is equality + +Expected: true +Received: false + at Object.<anonymous> (C:\workspace\whatever-template\src\components\TestFile.spec.ts:96:59) + Error: expect.assertions(3) + +Expected three assertions to be called but received two assertion calls. + at Object.<anonymous> (C:\workspace\whatever-template\src\components\TestFile.spec.ts:80:12) + at Object.asyncJestTest (C:\workspace\whatever-template\node_modules\jest-jasmine2\build\jasmineAsyncInstall.js:102:37) + at C:\workspace\whatever-template\node_modules\jest-jasmine2\build\queueRunner.js:43:12 + at new Promise (<anonymous>) + at mapper (C:\workspace\whatever-template\node_modules\jest-jasmine2\build\queueRunner.js:26:19) + at C:\workspace\whatever-template\node_modules\jest-jasmine2\build\queueRunner.js:73:41 + at processTicksAndRejections (internal/process/task_queues.js:97:5) + + + + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit-no-message-or-type.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit-no-message-or-type.xml new file mode 100644 index 00000000..2b9f6e9a --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit-no-message-or-type.xml @@ -0,0 +1,10 @@ + + + + + timrAPITests/Tests/Utils/UtilTests.swift:23 + + + + + diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit.xml new file mode 100644 index 00000000..64bd6b2f --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit.xml @@ -0,0 +1,118 @@ + + + + + + + java.lang.AssertionError + at org.junit.Assert.fail(Assert.java:86) + at org.junit.Assert.fail(Assert.java:95) + at com.example.jenkinstest.ExampleUnitTest.failTest4(ExampleUnitTest.kt:44) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) + at org.junit.runners.ParentRunner.run(ParentRunner.java:363) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) + at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) + at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) + at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) + at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) + at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) + at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) + at java.lang.Thread.run(Thread.java:745) + + + + java.lang.AssertionError + at org.junit.Assert.fail(Assert.java:86) + at org.junit.Assert.fail(Assert.java:95) + at com.example.jenkinstest.ExampleUnitTest.failTest5(ExampleUnitTest.kt:39) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) + at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) + at org.junit.runners.ParentRunner.run(ParentRunner.java:363) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) + at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) + at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) + at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) + at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) + at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) + at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) + at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) + at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) + at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) + at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) + at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) + at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) + at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) + at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) + at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) + at java.lang.Thread.run(Thread.java:745) + + + + + + + diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit2.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit2.xml new file mode 100644 index 00000000..6effb2ef --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/junit2.xml @@ -0,0 +1,51 @@ + + + + + + + + + androidx.test.espresso.AppNotIdleException: Looped for 3838 iterations over 60 SECONDS. The following Idle Conditions failed . +at dalvik.system.VMStack.getThreadStackTrace(Native Method) +at java.lang.Thread.getStackTrace(Thread.java:1556) +at androidx.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:88) +at androidx.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:51) +at androidx.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312) +at androidx.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:173) +at androidx.test.espresso.ViewInteraction.perform(ViewInteraction.java:114) +at my.company.MainActivityTest.openAppInfoTest(MainActivityTest.java:113) +at java.lang.reflect.Method.invoke(Native Method) +at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) +at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) +at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) +at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) +at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80) +at androidx.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:527) +at org.junit.rules.RunRules.evaluate(RunRules.java:20) +at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) +at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) +at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) +at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) +at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) +at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) +at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) +at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) +at org.junit.runners.ParentRunner.run(ParentRunner.java:363) +at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104) +at org.junit.runners.Suite.runChild(Suite.java:128) +at org.junit.runners.Suite.runChild(Suite.java:27) +at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) +at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) +at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) +at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) +at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) +at org.junit.runners.ParentRunner.run(ParentRunner.java:363) +at org.junit.runner.JUnitCore.run(JUnitCore.java:137) +at org.junit.runner.JUnitCore.run(JUnitCore.java:115) +at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) +at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388) +at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2119) + + + \ No newline at end of file diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/plainerror.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/plainerror.xml new file mode 100644 index 00000000..455d066e --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/plainerror.xml @@ -0,0 +1,4 @@ + + + diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/junit/without-message-with-type.xml b/src/test/resources/edu/hm/hafner/coverage/parser/junit/without-message-with-type.xml new file mode 100644 index 00000000..4ce0aa9b --- /dev/null +++ b/src/test/resources/edu/hm/hafner/coverage/parser/junit/without-message-with-type.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + but was: + at de.tobiasmichael.me.MyTest.testConcatenate4(MyTest.java:35) +]]> + + diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/mutation-with-blocks-and-indexes.xml b/src/test/resources/edu/hm/hafner/coverage/parser/pit/mutation-with-blocks-and-indexes.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/mutation-with-blocks-and-indexes.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/pit/mutation-with-blocks-and-indexes.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/mutation.xml b/src/test/resources/edu/hm/hafner/coverage/parser/pit/mutation.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/mutation.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/pit/mutation.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/mutations-codingstyle.xml b/src/test/resources/edu/hm/hafner/coverage/parser/pit/mutations-codingstyle.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/mutations-codingstyle.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/pit/mutations-codingstyle.xml diff --git a/src/test/resources/edu/hm/hafner/coverage/parser/mutations.xml b/src/test/resources/edu/hm/hafner/coverage/parser/pit/mutations.xml similarity index 100% rename from src/test/resources/edu/hm/hafner/coverage/parser/mutations.xml rename to src/test/resources/edu/hm/hafner/coverage/parser/pit/mutations.xml From 461400b9657c55359a42e1a890ce8dc9a27a252e Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 17:41:40 +0100 Subject: [PATCH 2/7] Fix JavaDoc. --- .github/release-drafter.yml | 2 +- src/main/java/edu/hm/hafner/coverage/Mutation.java | 2 +- src/main/java/edu/hm/hafner/coverage/TestCase.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 7f99f6ce..b3371837 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -20,7 +20,7 @@ categories: label: dependencies - title: 🔧 Internal Changes label: internal - - title: 🚦 TestCount + - title: 🚦 Tests label: tests version-resolver: diff --git a/src/main/java/edu/hm/hafner/coverage/Mutation.java b/src/main/java/edu/hm/hafner/coverage/Mutation.java index ca3e437a..08e0431e 100644 --- a/src/main/java/edu/hm/hafner/coverage/Mutation.java +++ b/src/main/java/edu/hm/hafner/coverage/Mutation.java @@ -11,7 +11,7 @@ import edu.hm.hafner.util.TreeStringBuilder; /** - * Class which represents a mutation of the PIT Mutation Testing tool. + * Represents a mutation of the PIT Mutation Testing tool. * * @author Melissa Bauer */ diff --git a/src/main/java/edu/hm/hafner/coverage/TestCase.java b/src/main/java/edu/hm/hafner/coverage/TestCase.java index 935d0f75..7fdb76e2 100644 --- a/src/main/java/edu/hm/hafner/coverage/TestCase.java +++ b/src/main/java/edu/hm/hafner/coverage/TestCase.java @@ -7,7 +7,7 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; /** - * Class which represents a test case. + * Represents a test case that has been executed. * * @author Ullrich Hafner */ From af159991052bc34e794b7b1fe0a3160751cae320 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 18:47:36 +0100 Subject: [PATCH 3/7] Use abstract test pattern vor `IntegerValue` instances. --- .../coverage/CyclomaticComplexityTest.java | 62 +------------- .../hm/hafner/coverage/IntegerValueTest.java | 84 +++++++++++++++---- .../hm/hafner/coverage/LinesOfCodeTest.java | 81 +----------------- .../edu/hm/hafner/coverage/TestCaseTest.java | 12 +++ .../edu/hm/hafner/coverage/TestCountTest.java | 8 ++ 5 files changed, 97 insertions(+), 150 deletions(-) create mode 100644 src/test/java/edu/hm/hafner/coverage/TestCaseTest.java create mode 100644 src/test/java/edu/hm/hafner/coverage/TestCountTest.java diff --git a/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java b/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java index 27ffeb05..b6d42bca 100644 --- a/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java +++ b/src/test/java/edu/hm/hafner/coverage/CyclomaticComplexityTest.java @@ -1,62 +1,8 @@ package edu.hm.hafner.coverage; -import org.junit.jupiter.api.Test; - -import edu.hm.hafner.coverage.Coverage.CoverageBuilder; - -import nl.jqno.equalsverifier.EqualsVerifier; - -import static edu.hm.hafner.coverage.assertions.Assertions.*; - -/** - * TestCount the class {@link CyclomaticComplexity}. - * - * @author Melissa Bauer - */ -class CyclomaticComplexityTest { - private static final Coverage COVERAGE = new CoverageBuilder().withMetric(Metric.LINE) - .withCovered(1) - .withMissed(1) - .build(); - - @Test - void shouldCreateComplexityLeaf() { - assertThat(new CyclomaticComplexity(125)).hasValue(125); - assertThat(new CyclomaticComplexity(0)).hasValue(0); - } - - @Test - void shouldCompareWithThreshold() { - assertThat(new CyclomaticComplexity(125).isOutOfValidRange(200)).isFalse(); - assertThat(new CyclomaticComplexity(125).isOutOfValidRange(125)).isFalse(); - assertThat(new CyclomaticComplexity(125).isOutOfValidRange(124.9)).isTrue(); - } - - @Test - void shouldOperateWithComplexities() { - assertThat(new CyclomaticComplexity(25).add(new CyclomaticComplexity(100))).hasValue(125); - assertThat(new CyclomaticComplexity(25).max(new CyclomaticComplexity(100))).hasValue(100); - assertThat(new CyclomaticComplexity(100).max(new CyclomaticComplexity(99))).hasValue(100); - } - - @Test - void shouldFailAddForInvalidTypes() { - assertThatIllegalArgumentException().isThrownBy(() -> - new CyclomaticComplexity(25).add(new LinesOfCode(100))); - assertThatIllegalArgumentException().isThrownBy(() -> - new CyclomaticComplexity(25).add(COVERAGE)); - } - - @Test - void shouldFailMaxForInvalidTypes() { - assertThatIllegalArgumentException().isThrownBy(() -> - new CyclomaticComplexity(25).max(new LinesOfCode(100))); - assertThatIllegalArgumentException().isThrownBy(() -> - new CyclomaticComplexity(25).max(COVERAGE)); - } - - @Test - void shouldAdhereToEquals() { - EqualsVerifier.forClass(CyclomaticComplexity.class).withRedefinedSuperclass().verify(); +class CyclomaticComplexityTest extends IntegerValueTest { + @Override + IntegerValue createValue(final int value) { + return new CyclomaticComplexity(value); } } diff --git a/src/test/java/edu/hm/hafner/coverage/IntegerValueTest.java b/src/test/java/edu/hm/hafner/coverage/IntegerValueTest.java index 143a252c..8573b0c6 100644 --- a/src/test/java/edu/hm/hafner/coverage/IntegerValueTest.java +++ b/src/test/java/edu/hm/hafner/coverage/IntegerValueTest.java @@ -3,32 +3,86 @@ import org.apache.commons.lang3.math.Fraction; import org.junit.jupiter.api.Test; +import nl.jqno.equalsverifier.EqualsVerifier; + import static edu.hm.hafner.coverage.assertions.Assertions.*; -class IntegerValueTest { +abstract class IntegerValueTest { + private static Fraction getDelta(final int value) { + return Fraction.getFraction(value, 1); + } + + abstract IntegerValue createValue(int value); + @Test void shouldThrowExceptionOnInvalidDeltaParameter() { - var linesOfCode = new LinesOfCode(20); + var value = createValue(20); + + var coverage = Coverage.nullObject(Metric.LINE); - var cyclomaticComplexity = new CyclomaticComplexity(10); assertThatIllegalArgumentException() - .isThrownBy(() -> linesOfCode.delta(cyclomaticComplexity)) + .isThrownBy(() -> value.delta(coverage)) + .withMessageContaining("Cannot cast incompatible types"); + assertThatIllegalArgumentException() + .isThrownBy(() -> value.add(coverage)) + .withMessageContaining("Cannot cast incompatible types"); + assertThatIllegalArgumentException() + .isThrownBy(() -> value.max(coverage)) .withMessageContaining("Cannot cast incompatible types"); - - var fractionValue = new FractionValue(Metric.LOC, Fraction.getFraction(1, 1)); assertThatIllegalArgumentException() - .isThrownBy(() -> linesOfCode.delta(fractionValue)) + .isThrownBy(() -> value.delta(coverage)) .withMessageContaining("Cannot cast incompatible types"); } @Test - void shouldSerialize() { - var linesOfCode = new LinesOfCode(20); - var cyclomaticComplexity = new CyclomaticComplexity(10); - - assertThat(linesOfCode.serialize()) - .isEqualTo("LOC: 20"); - assertThat(cyclomaticComplexity.serialize()) - .isEqualTo("COMPLEXITY: 10"); + void shouldCreateValue() { + assertThat(createValue(100)).hasValue(100); + assertThat(createValue(-100)).hasValue(-100); + assertThat(createValue(0)).hasValue(0); + + var value = createValue(123); + assertThat(value.serialize()).startsWith(value.getMetric().name()).endsWith(": 123"); + + assertThat(value.create(100)).hasValue(100); + assertThat(value.create(-100)).hasValue(-100); + assertThat(value.create(0)).hasValue(0); + } + + @Test + void shouldCompareWithThreshold() { + assertThat(createValue(125).isOutOfValidRange(200)).isFalse(); + assertThat(createValue(125).isOutOfValidRange(125)).isFalse(); + assertThat(createValue(125).isOutOfValidRange(124.9)).isTrue(); + } + + @Test + void shouldAddValues() { + assertThat(createValue(25).add(createValue(100))).hasValue(125); + assertThat(createValue(-25).add(createValue(100))).hasValue(75); + } + + @Test + void shouldFindMaximum() { + assertThat(createValue(25).max(createValue(26))).hasValue(26); + assertThat(createValue(26).max(createValue(25))).hasValue(26); + } + + @Test + void shouldComputeDelta() { + var large = createValue(1000); + var medium = createValue(100); + var small = createValue(10); + + assertThat(large.delta(medium)).isEqualTo(getDelta(900)); + assertThat(large.delta(small)).isEqualTo(getDelta(990)); + assertThat(medium.delta(small)).isEqualTo(getDelta(90)); + assertThat(medium.delta(large)).isEqualTo(getDelta(-900)); + assertThat(small.delta(large)).isEqualTo(getDelta(-990)); + assertThat(small.delta(medium)).isEqualTo(getDelta(-90)); + } + + @Test + void shouldAdhereToEquals() { + EqualsVerifier.forClass(createValue(0).getClass()).withRedefinedSuperclass().verify(); } } diff --git a/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java b/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java index d54cd3be..226b49b2 100644 --- a/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/LinesOfCodeTest.java @@ -1,81 +1,8 @@ package edu.hm.hafner.coverage; -import org.apache.commons.lang3.math.Fraction; -import org.junit.jupiter.api.Test; - -import edu.hm.hafner.coverage.Coverage.CoverageBuilder; - -import nl.jqno.equalsverifier.EqualsVerifier; - -import static edu.hm.hafner.coverage.assertions.Assertions.*; - -/** - * TestCount the class {@link CyclomaticComplexity}. - * - * @author Melissa Bauer - */ -class LinesOfCodeTest { - private static final Coverage COVERAGE = new CoverageBuilder().withMetric(Metric.LINE) - .withCovered(1) - .withMissed(1) - .build(); - - @Test - void shouldCreateComplexityLeaf() { - assertThat(new LinesOfCode(125)).hasValue(125); - assertThat(new LinesOfCode(0)).hasValue(0); - } - - @Test - void shouldCompareWithThreshold() { - assertThat(new LinesOfCode(125).isOutOfValidRange(200)).isFalse(); - assertThat(new LinesOfCode(125).isOutOfValidRange(125)).isFalse(); - assertThat(new LinesOfCode(125).isOutOfValidRange(124.9)).isTrue(); - } - - @Test - void shouldOperateWithLoc() { - assertThat(new LinesOfCode(25).add(new LinesOfCode(100))).hasValue(125); - assertThat(new LinesOfCode(25).max(new LinesOfCode(100))).hasValue(100); - assertThat(new LinesOfCode(100).max(new LinesOfCode(99))).hasValue(100); - } - - @Test - void shouldComputeDelta() { - var large = new LinesOfCode(1000); - var medium = new LinesOfCode(100); - var small = new LinesOfCode(10); - - assertThat(large.delta(medium)).isEqualTo(getDelta(900)); - assertThat(large.delta(small)).isEqualTo(getDelta(990)); - assertThat(medium.delta(small)).isEqualTo(getDelta(90)); - assertThat(medium.delta(large)).isEqualTo(getDelta(-900)); - assertThat(small.delta(large)).isEqualTo(getDelta(-990)); - assertThat(small.delta(medium)).isEqualTo(getDelta(-90)); - } - - private static Fraction getDelta(final int value) { - return Fraction.getFraction(value, 1); - } - - @Test - void shouldFailAddForInvalidTypes() { - assertThatIllegalArgumentException().isThrownBy(() -> - new LinesOfCode(25).add(new CyclomaticComplexity(100))); - assertThatIllegalArgumentException().isThrownBy(() -> - new LinesOfCode(25).add(COVERAGE)); - } - - @Test - void shouldFailMaxForInvalidTypes() { - assertThatIllegalArgumentException().isThrownBy(() -> - new LinesOfCode(25).max(new CyclomaticComplexity(100))); - assertThatIllegalArgumentException().isThrownBy(() -> - new LinesOfCode(25).max(COVERAGE)); - } - - @Test - void shouldAdhereToEquals() { - EqualsVerifier.forClass(CyclomaticComplexity.class).withRedefinedSuperclass().verify(); +class LinesOfCodeTest extends IntegerValueTest { + @Override + IntegerValue createValue(final int value) { + return new LinesOfCode(value); } } diff --git a/src/test/java/edu/hm/hafner/coverage/TestCaseTest.java b/src/test/java/edu/hm/hafner/coverage/TestCaseTest.java new file mode 100644 index 00000000..a80159b8 --- /dev/null +++ b/src/test/java/edu/hm/hafner/coverage/TestCaseTest.java @@ -0,0 +1,12 @@ +package edu.hm.hafner.coverage; + +import org.junit.jupiter.api.Test; + +import nl.jqno.equalsverifier.EqualsVerifier; + +class TestCaseTest { + @Test + void shouldAdhereToEquals() { + EqualsVerifier.forClass(TestCase.class).verify(); + } +} diff --git a/src/test/java/edu/hm/hafner/coverage/TestCountTest.java b/src/test/java/edu/hm/hafner/coverage/TestCountTest.java new file mode 100644 index 00000000..7ecfce96 --- /dev/null +++ b/src/test/java/edu/hm/hafner/coverage/TestCountTest.java @@ -0,0 +1,8 @@ +package edu.hm.hafner.coverage; + +class TestCountTest extends IntegerValueTest { + @Override + IntegerValue createValue(final int value) { + return new TestCount(value); + } +} From 53987c2fe22b0f130f49323ac98f086ee46d9bb6 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 19:54:32 +0100 Subject: [PATCH 4/7] Fix warnings. --- src/main/java/edu/hm/hafner/coverage/Value.java | 2 ++ .../edu/hm/hafner/coverage/parser/AbstractParserTest.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/main/java/edu/hm/hafner/coverage/Value.java b/src/main/java/edu/hm/hafner/coverage/Value.java index 4ff2c539..718770bd 100644 --- a/src/main/java/edu/hm/hafner/coverage/Value.java +++ b/src/main/java/edu/hm/hafner/coverage/Value.java @@ -99,6 +99,8 @@ public static Value valueOf(final String stringRepresentation) { return new CyclomaticComplexity(Integer.parseInt(value), Metric.COMPLEXITY_MAXIMUM); case LOC: return new LinesOfCode(Integer.parseInt(value)); + case TESTS: + return new TestCount(Integer.parseInt(value)); } } } diff --git a/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java index 59e75f84..8fd7b483 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/AbstractParserTest.java @@ -10,10 +10,13 @@ import org.junit.jupiter.api.Test; +import com.google.errorprone.annotations.MustBeClosed; + import edu.hm.hafner.coverage.CoverageParser; import edu.hm.hafner.coverage.ModuleNode; import edu.hm.hafner.util.FilteredLog; import edu.hm.hafner.util.SecureXmlParserFactory.ParsingException; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import static org.assertj.core.api.Assertions.*; @@ -41,7 +44,9 @@ ModuleNode readReport(final String fileName, final CoverageParser parser) { } } + @MustBeClosed @SuppressWarnings("resource") + @SuppressFBWarnings("OBL") private InputStream createFile(final String fileName) { var file = AbstractParserTest.class.getResourceAsStream(fileName); if (file == null) { From 6a5d3f594e22405b8b6ecf186369d97ac9e523a8 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 22:36:05 +0100 Subject: [PATCH 5/7] Improve coverage. --- .../java/edu/hm/hafner/coverage/TestCase.java | 4 +++- .../java/edu/hm/hafner/coverage/ValueTest.java | 17 ++++++++--------- .../hafner/coverage/parser/JunitParserTest.java | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/edu/hm/hafner/coverage/TestCase.java b/src/main/java/edu/hm/hafner/coverage/TestCase.java index 7fdb76e2..ad656bd4 100644 --- a/src/main/java/edu/hm/hafner/coverage/TestCase.java +++ b/src/main/java/edu/hm/hafner/coverage/TestCase.java @@ -6,6 +6,8 @@ import com.google.errorprone.annotations.CanIgnoreReturnValue; +import edu.hm.hafner.util.Generated; + /** * Represents a test case that has been executed. * @@ -84,7 +86,7 @@ public boolean equals(final Object o) { return description.equals(testCase.description); } - @Override + @Override @Generated public String toString() { return "TestCase{testName='" + testName + '\'' + ", className='" + className + '\'' + ", status=" + status + ", type='" + type + '\'' + ", message='" + message + '\'' + ", description='" + description + '\'' diff --git a/src/test/java/edu/hm/hafner/coverage/ValueTest.java b/src/test/java/edu/hm/hafner/coverage/ValueTest.java index aa90097c..3f018191 100644 --- a/src/test/java/edu/hm/hafner/coverage/ValueTest.java +++ b/src/test/java/edu/hm/hafner/coverage/ValueTest.java @@ -11,7 +11,6 @@ import static edu.hm.hafner.coverage.assertions.Assertions.*; class ValueTest { - @Test void shouldReturnCorrectValueOfCoverage() { Value container = Value.valueOf("CONTAINER: 1/1"); @@ -53,13 +52,13 @@ void shouldReturnCorrectValueOfFractionValue() { } @Test - void shouldReturnCorrectValueOfCyclomaticComplexity() { - Value cyclomaticComplexity = Value.valueOf("COMPLEXITY: 1"); - - assertThat(cyclomaticComplexity) - .isInstanceOf(CyclomaticComplexity.class); - assertThat((CyclomaticComplexity) cyclomaticComplexity) - .hasValue(1); + void shouldReturnCorrectValueOfIntegerValues() { + assertThat(Value.valueOf("COMPLEXITY: 1")) + .isInstanceOfSatisfying(CyclomaticComplexity.class, value -> assertThat(value).hasValue(1)); + assertThat(Value.valueOf("LOC: 2")) + .isInstanceOfSatisfying(LinesOfCode.class, value -> assertThat(value).hasValue(2)); + assertThat(Value.valueOf("TESTS: 3")) + .isInstanceOfSatisfying(TestCount.class, value -> assertThat(value).hasValue(3)); } @Test @@ -105,4 +104,4 @@ void shouldGetValue() { void shouldAdhereToEquals() { EqualsVerifier.simple().forClass(Value.class).verify(); } -} \ No newline at end of file +} diff --git a/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java index 2054a2c4..407fe6e5 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java @@ -51,7 +51,8 @@ void shouldReadArchUnitTests() { var testCase = getFirstTest(tree); assertThat(testCase).hasStatus(TestResult.FAILED) .hasClassName("Aufgabe3Test") - .hasTestName("shouldSplitToEmptyRight(int)[1]"); + .hasTestName("shouldSplitToEmptyRight(int)[1]") + .hasType("org.opentest4j.AssertionFailedError"); assertThat(testCase.getMessage()).isEmpty(); assertThat(testCase.getDescription()).contains( "at Aufgabe3Test.shouldSplitToEmptyRight(Aufgabe3Test.java:254)"); From 1297501ba6060c9785bfa3134282c1b0df2b89fa Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Fri, 17 Nov 2023 22:38:51 +0100 Subject: [PATCH 6/7] Add JUnit parser to registry. --- .../hm/hafner/coverage/registry/ParserRegistry.java | 6 +++++- .../hafner/coverage/registry/ParserRegistryTest.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/hm/hafner/coverage/registry/ParserRegistry.java b/src/main/java/edu/hm/hafner/coverage/registry/ParserRegistry.java index 2a428565..6510033c 100644 --- a/src/main/java/edu/hm/hafner/coverage/registry/ParserRegistry.java +++ b/src/main/java/edu/hm/hafner/coverage/registry/ParserRegistry.java @@ -6,6 +6,7 @@ import edu.hm.hafner.coverage.CoverageParser.ProcessingMode; import edu.hm.hafner.coverage.parser.CoberturaParser; import edu.hm.hafner.coverage.parser.JacocoParser; +import edu.hm.hafner.coverage.parser.JunitParser; import edu.hm.hafner.coverage.parser.PitestParser; /** @@ -18,7 +19,8 @@ public class ParserRegistry { public enum CoverageParserType { COBERTURA, JACOCO, - PIT + PIT, + JUNIT } /** @@ -58,6 +60,8 @@ public CoverageParser getParser(final CoverageParserType parser, final Processin return new JacocoParser(); case PIT: return new PitestParser(); + case JUNIT: + return new JunitParser(); } throw new IllegalArgumentException("Unknown parser type: " + parser); } diff --git a/src/test/java/edu/hm/hafner/coverage/registry/ParserRegistryTest.java b/src/test/java/edu/hm/hafner/coverage/registry/ParserRegistryTest.java index 131e1a35..4cf6859c 100644 --- a/src/test/java/edu/hm/hafner/coverage/registry/ParserRegistryTest.java +++ b/src/test/java/edu/hm/hafner/coverage/registry/ParserRegistryTest.java @@ -5,6 +5,8 @@ import edu.hm.hafner.coverage.CoverageParser.ProcessingMode; import edu.hm.hafner.coverage.parser.CoberturaParser; import edu.hm.hafner.coverage.parser.JacocoParser; +import edu.hm.hafner.coverage.parser.JunitParser; +import edu.hm.hafner.coverage.parser.PitestParser; import edu.hm.hafner.coverage.registry.ParserRegistry.CoverageParserType; import static org.assertj.core.api.Assertions.*; @@ -14,8 +16,14 @@ class ParserRegistryTest { void shouldCreateSomeParsers() { var registry = new ParserRegistry(); - assertThat(registry.getParser(CoverageParserType.COBERTURA.name(), ProcessingMode.FAIL_FAST)).isInstanceOf(CoberturaParser.class); - assertThat(registry.getParser(CoverageParserType.JACOCO, ProcessingMode.IGNORE_ERRORS)).isInstanceOf(JacocoParser.class); + assertThat(registry.getParser(CoverageParserType.COBERTURA.name(), ProcessingMode.FAIL_FAST)) + .isInstanceOf(CoberturaParser.class); + assertThat(registry.getParser(CoverageParserType.JACOCO, ProcessingMode.IGNORE_ERRORS)) + .isInstanceOf(JacocoParser.class); + assertThat(registry.getParser(CoverageParserType.PIT.name(), ProcessingMode.FAIL_FAST)) + .isInstanceOf(PitestParser.class); + assertThat(registry.getParser(CoverageParserType.JUNIT, ProcessingMode.IGNORE_ERRORS)) + .isInstanceOf(JunitParser.class); } @Test From 111cd9cc131d3c68800e3f7f7d1b722d5c3bbe93 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Mon, 20 Nov 2023 10:03:23 +0100 Subject: [PATCH 7/7] Add test cases and mutations to API of `Node`. --- .../edu/hm/hafner/coverage/ClassNode.java | 1 + .../java/edu/hm/hafner/coverage/FileNode.java | 1 + .../java/edu/hm/hafner/coverage/Node.java | 26 +++++++++++++++++-- .../java/edu/hm/hafner/coverage/NodeTest.java | 16 ++++++------ .../coverage/parser/JunitParserTest.java | 8 ++---- .../coverage/parser/PitestParserTest.java | 3 +++ 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/src/main/java/edu/hm/hafner/coverage/ClassNode.java b/src/main/java/edu/hm/hafner/coverage/ClassNode.java index 21e6721f..1e3aca52 100644 --- a/src/main/java/edu/hm/hafner/coverage/ClassNode.java +++ b/src/main/java/edu/hm/hafner/coverage/ClassNode.java @@ -71,6 +71,7 @@ public void addTestCase(final TestCase testCase) { replaceValue(new TestCount(testCases.size())); } + @Override public List getTestCases() { return testCases; } diff --git a/src/main/java/edu/hm/hafner/coverage/FileNode.java b/src/main/java/edu/hm/hafner/coverage/FileNode.java index 8307a276..0afd557a 100644 --- a/src/main/java/edu/hm/hafner/coverage/FileNode.java +++ b/src/main/java/edu/hm/hafner/coverage/FileNode.java @@ -673,6 +673,7 @@ public void addMutation(final Mutation mutation) { mutations.add(mutation); } + @Override public List getMutations() { return Collections.unmodifiableList(mutations); } diff --git a/src/main/java/edu/hm/hafner/coverage/Node.java b/src/main/java/edu/hm/hafner/coverage/Node.java index 1817f993..c0c5e9be 100644 --- a/src/main/java/edu/hm/hafner/coverage/Node.java +++ b/src/main/java/edu/hm/hafner/coverage/Node.java @@ -458,6 +458,20 @@ public Optional findMethod(final String searchName, final String sea .findAny(); } + public List getMutations() { + return getChildren().stream() + .map(Node::getMutations) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + } + + public List getTestCases() { + return getChildren().stream() + .map(Node::getTestCases) + .flatMap(Collection::stream) + .collect(Collectors.toList()); + } + /** * Returns the file names that are contained within the subtree of this node. * @@ -468,11 +482,19 @@ public Set getFiles() { } public List getAllFileNodes() { - return getAll(Metric.FILE).stream().map(FileNode.class::cast).collect(Collectors.toList()); + return getAll(Metric.FILE, FileNode.class::cast); + } + + public List getAllClassNodes() { + return getAll(Metric.CLASS, ClassNode.class::cast); } public List getAllMethodNodes() { - return getAll(Metric.METHOD).stream().map(MethodNode.class::cast).collect(Collectors.toList()); + return getAll(Metric.METHOD, MethodNode.class::cast); + } + + private List getAll(final Metric metric1, final Function cast) { + return getAll(metric1).stream().map(cast).collect(Collectors.toList()); } /** diff --git a/src/test/java/edu/hm/hafner/coverage/NodeTest.java b/src/test/java/edu/hm/hafner/coverage/NodeTest.java index 59bde306..e16fdb71 100644 --- a/src/test/java/edu/hm/hafner/coverage/NodeTest.java +++ b/src/test/java/edu/hm/hafner/coverage/NodeTest.java @@ -59,11 +59,8 @@ void shouldReturnParentOfNodeAndItsName() { assertThat(child.getParent()).isEqualTo(parent); - //boundary-interior demonstration (Path "Don't enter loop" is impossible in this case) - assertThat(child.getParentName()).isEqualTo("Parent"); // boundary -> Enter only once and cover all branches - assertThat(subSubPackage.getParentName()).isEqualTo( - "Child.SubPackage"); // interior -> Enter twice and cover all branches - + assertThat(child.getParentName()).isEqualTo("Parent"); + assertThat(subSubPackage.getParentName()).isEqualTo("Child.SubPackage"); } @Test @@ -727,8 +724,6 @@ void shouldMergeMultipleNodesWithDifferentMetricInList() { @Test void shouldGetAllNodesOfTypeInTree() { Node tree = createTreeWithoutCoverage(); - FileNode coveredFile = tree.findFile("Covered.java").orElseThrow(); - FileNode missedFile = tree.findFile("Missed.java").orElseThrow(); MethodNode coveredMethod = new MethodNode("coveredMethod", "signature"); MethodNode missedMethod = new MethodNode("missedMethod", "signature"); @@ -736,7 +731,12 @@ void shouldGetAllNodesOfTypeInTree() { tree.findClass(MISSED_CLASS).orElseThrow().addChild(missedMethod); assertThat(tree.getAllMethodNodes()).containsExactlyInAnyOrder(coveredMethod, missedMethod); - assertThat(tree.getAllFileNodes()).containsExactlyInAnyOrder(coveredFile, missedFile); + assertThat(tree.getAllFileNodes()).containsExactlyInAnyOrder( + tree.findFile("Covered.java").orElseThrow(), + tree.findFile("Missed.java").orElseThrow()); + assertThat(tree.getAllClassNodes()).containsExactlyInAnyOrder( + tree.findClass("CoveredClass.class").orElseThrow(), + tree.findClass("MissedClass.class").orElseThrow()); } @Test diff --git a/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java index 407fe6e5..acaec1f5 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/JunitParserTest.java @@ -72,12 +72,8 @@ void shouldReadWithNameOnly() { assertThat(getFirstClass(tree)).hasName("CloudFormation Lint"); assertThat(tree.aggregateValues()).contains(new TestCount(141)); - assertThat(tree.getAll(Metric.CLASS).stream() - .map(ClassNode.class::cast) - .map(ClassNode::getTestCases) - .flatMap(Collection::stream) - .filter(test -> test.getStatus() == TestResult.SKIPPED) - .count()).isEqualTo(19); + assertThat(tree.getTestCases()).hasSize(141) + .filteredOn(test -> test.getStatus() == TestResult.SKIPPED).hasSize(19); } @Test diff --git a/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java b/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java index 7879018e..7fabf605 100644 --- a/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java +++ b/src/test/java/edu/hm/hafner/coverage/parser/PitestParserTest.java @@ -44,6 +44,8 @@ void shouldReadAllMutationProperties() { .hasKillingTest("edu.hm.hafner.coverage.CoverageNodeTest.[engine:junit-jupiter]/[class:edu.hm.hafner.coverage.CoverageNodeTest]/[method:shouldAddChildren()]") .hasDescription("removed call to edu/hm/hafner/coverage/CoverageNode::setParent") )); + + assertThat(tree.getMutations()).hasSize(1); } @Test @@ -78,6 +80,7 @@ void shouldMapLineCoveragesForPainting() { assertThat(tree.findFile(LOOKAHEAD_STREAM)).isPresent().get().satisfies(this::verifyLookaheadStream); assertThat(tree.findFile(FILTERED_LOG)).isPresent().get().satisfies(this::verifyFilteredLog); assertThat(tree.findFile(ENSURE)).isPresent().get().satisfies(this::verifyEnsure); + assertThat(tree.getMutations()).hasSize(234); } private void verifyEnsure(final FileNode file) {