"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "junit-platform-runner/src/main/java/org/junit/platform/runner/JUnitPlatformTestTree.java" between
junit5-r5.3.2.tar.gz and junit5-r5.4.0.tar.gz

About: JUnit 5 is a unit testing framework for the Java programming language.

JUnitPlatformTestTree.java  (junit5-r5.3.2):JUnitPlatformTestTree.java  (junit5-r5.4.0)
/* /*
* Copyright 2015-2018 the original author or authors. * Copyright 2015-2019 the original author or authors.
* *
* All rights reserved. This program and the accompanying materials are * All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which * made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at * accompanies this distribution and is available at
* *
* http://www.eclipse.org/legal/epl-v20.html * http://www.eclipse.org/legal/epl-v20.html
*/ */
package org.junit.platform.runner; package org.junit.platform.runner;
skipping to change at line 43 skipping to change at line 43
import org.junit.platform.suite.api.UseTechnicalNames; import org.junit.platform.suite.api.UseTechnicalNames;
import org.junit.runner.Description; import org.junit.runner.Description;
import org.junit.runner.manipulation.Filter; import org.junit.runner.manipulation.Filter;
/** /**
* @since 1.0 * @since 1.0
*/ */
class JUnitPlatformTestTree { class JUnitPlatformTestTree {
private final Map<TestIdentifier, Description> descriptions = new HashMap <>(); private final Map<TestIdentifier, Description> descriptions = new HashMap <>();
private final TestPlan plan; private final TestPlan testPlan;
private final Function<TestIdentifier, String> nameExtractor; private final Function<TestIdentifier, String> nameExtractor;
private final Description suiteDescription; private final Description suiteDescription;
JUnitPlatformTestTree(TestPlan plan, Class<?> testClass) { JUnitPlatformTestTree(TestPlan testPlan, Class<?> testClass) {
this.plan = plan; this.testPlan = testPlan;
this.nameExtractor = useTechnicalNames(testClass) ? this::getTech nicalName : TestIdentifier::getDisplayName; this.nameExtractor = useTechnicalNames(testClass) ? this::getTech nicalName : TestIdentifier::getDisplayName;
this.suiteDescription = generateSuiteDescription(plan, testClass) this.suiteDescription = generateSuiteDescription(testPlan, testCl
; ass);
}
public TestPlan getTestPlan() {
return testPlan;
} }
private static boolean useTechnicalNames(Class<?> testClass) { private static boolean useTechnicalNames(Class<?> testClass) {
return testClass.isAnnotationPresent(UseTechnicalNames.class); return testClass.isAnnotationPresent(UseTechnicalNames.class);
} }
Description getSuiteDescription() { Description getSuiteDescription() {
return this.suiteDescription; return this.suiteDescription;
} }
skipping to change at line 86 skipping to change at line 90
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)
.orElse(testClass.getName()); .orElse(testClass.getName());
// @formatter:on // @formatter:on
} }
private void buildDescriptionTree(Description suiteDescription, TestPlan testPlan) { private void buildDescriptionTree(Description suiteDescription, TestPlan testPlan) {
testPlan.getRoots().forEach(testIdentifier -> buildDescription(te stIdentifier, suiteDescription, testPlan)); testPlan.getRoots().forEach(testIdentifier -> buildDescription(te stIdentifier, suiteDescription, testPlan));
} }
void addDynamicDescription(TestIdentifier newIdentifier, String parentId) { void addDynamicDescription(TestIdentifier newIdentifier, String parentId) {
Description parent = getDescription(this.plan.getTestIdentifier(p Description parent = getDescription(this.testPlan.getTestIdentifi
arentId)); er(parentId));
this.plan.add(newIdentifier); buildDescription(newIdentifier, parent, this.testPlan);
buildDescription(newIdentifier, parent, this.plan);
} }
private void buildDescription(TestIdentifier identifier, Description pare nt, TestPlan testPlan) { private void buildDescription(TestIdentifier identifier, Description pare nt, TestPlan testPlan) {
Description newDescription = createJUnit4Description(identifier, testPlan); Description newDescription = createJUnit4Description(identifier, testPlan);
parent.addChild(newDescription); parent.addChild(newDescription);
this.descriptions.put(identifier, newDescription); this.descriptions.put(identifier, newDescription);
testPlan.getChildren(identifier).forEach( testPlan.getChildren(identifier).forEach(
testIdentifier -> buildDescription(testIdentifier, newDes cription, testPlan)); testIdentifier -> buildDescription(testIdentifier, newDes cription, testPlan));
} }
skipping to change at line 131 skipping to change at line 134
return String.format("%s(%s)", methodSource.getMe thodName(), methodParameterTypes); return String.format("%s(%s)", methodSource.getMe thodName(), methodParameterTypes);
} }
} }
// Else fall back to display name // Else fall back to display name
return testIdentifier.getDisplayName(); return testIdentifier.getDisplayName();
} }
Set<TestIdentifier> getTestsInSubtree(TestIdentifier ancestor) { Set<TestIdentifier> getTestsInSubtree(TestIdentifier ancestor) {
// @formatter:off // @formatter:off
return plan.getDescendants(ancestor).stream() return testPlan.getDescendants(ancestor).stream()
.filter(TestIdentifier::isTest) .filter(TestIdentifier::isTest)
.collect(toCollection(LinkedHashSet::new)); .collect(toCollection(LinkedHashSet::new));
// @formatter:on // @formatter:on
} }
Set<TestIdentifier> getFilteredLeaves(Filter filter) { Set<TestIdentifier> getFilteredLeaves(Filter filter) {
Set<TestIdentifier> identifiers = applyFilterToDescriptions(filte r); Set<TestIdentifier> identifiers = applyFilterToDescriptions(filte r);
return removeNonLeafIdentifiers(identifiers); return removeNonLeafIdentifiers(identifiers);
} }
private Set<TestIdentifier> removeNonLeafIdentifiers(Set<TestIdentifier> identifiers) { private Set<TestIdentifier> removeNonLeafIdentifiers(Set<TestIdentifier> identifiers) {
return identifiers.stream().filter(isALeaf(identifiers)).collect( toSet()); return identifiers.stream().filter(isALeaf(identifiers)).collect( toSet());
} }
private Predicate<? super TestIdentifier> isALeaf(Set<TestIdentifier> ide ntifiers) { private Predicate<? super TestIdentifier> isALeaf(Set<TestIdentifier> ide ntifiers) {
return testIdentifier -> { return testIdentifier -> {
Set<TestIdentifier> descendants = plan.getDescendants(tes tIdentifier); Set<TestIdentifier> descendants = testPlan.getDescendants (testIdentifier);
return identifiers.stream().noneMatch(descendants::contai ns); return identifiers.stream().noneMatch(descendants::contai ns);
}; };
} }
private Set<TestIdentifier> applyFilterToDescriptions(Filter filter) { private Set<TestIdentifier> applyFilterToDescriptions(Filter filter) {
// @formatter:off // @formatter:off
return descriptions.entrySet() return descriptions.entrySet()
.stream() .stream()
.filter(entry -> filter.shouldRun(entry.getValue( ))) .filter(entry -> filter.shouldRun(entry.getValue( )))
.map(Entry::getKey) .map(Entry::getKey)
 End of changes. 7 change blocks. 
12 lines changed or deleted 15 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)