"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/MethodBasedTestDescriptor.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.

MethodBasedTestDescriptor.java  (junit5-r5.3.2):MethodBasedTestDescriptor.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.jupiter.engine.descriptor; package org.junit.jupiter.engine.descriptor;
import static org.apiguardian.api.API.Status.INTERNAL;
import static org.junit.jupiter.engine.descriptor.DisplayNameUtils.determineDisp
layNameForMethod;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.apiguardian.api.API;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.platform.commons.util.ClassUtils; import org.junit.platform.commons.util.ClassUtils;
import org.junit.platform.commons.util.Preconditions; import org.junit.platform.commons.util.Preconditions;
import org.junit.platform.engine.TestDescriptor; import org.junit.platform.engine.TestDescriptor;
import org.junit.platform.engine.TestTag; import org.junit.platform.engine.TestTag;
import org.junit.platform.engine.UniqueId; import org.junit.platform.engine.UniqueId;
import org.junit.platform.engine.support.descriptor.MethodSource; import org.junit.platform.engine.support.descriptor.MethodSource;
import org.junit.platform.engine.support.hierarchical.ExclusiveResource; import org.junit.platform.engine.support.hierarchical.ExclusiveResource;
/** /**
* Base class for {@link TestDescriptor TestDescriptors} based on Java methods. * Base class for {@link TestDescriptor TestDescriptors} based on Java methods.
*
* @since 5.0
*/ */
abstract class MethodBasedTestDescriptor extends JupiterTestDescriptor { @API(status = INTERNAL, since = "5.0")
public abstract class MethodBasedTestDescriptor extends JupiterTestDescriptor {
private final Class<?> testClass; private final Class<?> testClass;
private final Method testMethod; private final Method testMethod;
/** /**
* Set of method-level tags; does not contain tags from parent. * Set of method-level tags; does not contain tags from parent.
*/ */
private final Set<TestTag> tags; private final Set<TestTag> tags;
MethodBasedTestDescriptor(UniqueId uniqueId, Class<?> testClass, Method t MethodBasedTestDescriptor(UniqueId uniqueId, Class<?> testClass, Method t
estMethod) { estMethod,
this(uniqueId, determineDisplayName(Preconditions.notNull(testMet JupiterConfiguration configuration) {
hod, "Method must not be null"), this(uniqueId, determineDisplayNameForMethod(testClass, testMetho
MethodBasedTestDescriptor::generateDefaultDisplayName), t d), testClass, testMethod, configuration);
estClass, testMethod);
} }
MethodBasedTestDescriptor(UniqueId uniqueId, String displayName, Class<?> MethodBasedTestDescriptor(UniqueId uniqueId, String displayName, Class<?>
testClass, Method testMethod) { testClass, Method testMethod,
super(uniqueId, displayName, MethodSource.from(testClass, testMet JupiterConfiguration configuration) {
hod)); super(uniqueId, displayName, MethodSource.from(testClass, testMet
hod), configuration);
this.testClass = Preconditions.notNull(testClass, "Class must not be null"); this.testClass = Preconditions.notNull(testClass, "Class must not be null");
this.testMethod = testMethod; this.testMethod = testMethod;
this.tags = getTags(testMethod); this.tags = getTags(testMethod);
} }
@Override @Override
public final Set<TestTag> getTags() { public final Set<TestTag> getTags() {
// return modifiable copy // return modifiable copy
Set<TestTag> allTags = new LinkedHashSet<>(this.tags); Set<TestTag> allTags = new LinkedHashSet<>(this.tags);
getParent().ifPresent(parentDescriptor -> allTags.addAll(parentDe scriptor.getTags())); getParent().ifPresent(parentDescriptor -> allTags.addAll(parentDe scriptor.getTags()));
return allTags; return allTags;
} }
@Override @Override
public Set<ExclusiveResource> getExclusiveResources() { public Set<ExclusiveResource> getExclusiveResources() {
return getExclusiveResourcesFromAnnotation(getTestMethod()); return getExclusiveResourcesFromAnnotation(getTestMethod());
} }
@Override
protected Optional<ExecutionMode> getExplicitExecutionMode() { protected Optional<ExecutionMode> getExplicitExecutionMode() {
return getExecutionModeFromAnnotation(getTestMethod()); return getExecutionModeFromAnnotation(getTestMethod());
} }
public final Class<?> getTestClass() { public final Class<?> getTestClass() {
return this.testClass; return this.testClass;
} }
public final Method getTestMethod() { public final Method getTestMethod() {
return this.testMethod; return this.testMethod;
} }
@Override @Override
public String getLegacyReportingName() { public String getLegacyReportingName() {
return generateDefaultDisplayName(testMethod);
}
private static String generateDefaultDisplayName(Method testMethod) {
return String.format("%s(%s)", testMethod.getName(), return String.format("%s(%s)", testMethod.getName(),
ClassUtils.nullSafeToString(Class::getSimpleName, testMet hod.getParameterTypes())); ClassUtils.nullSafeToString(Class::getSimpleName, testMet hod.getParameterTypes()));
} }
} }
 End of changes. 9 change blocks. 
16 lines changed or deleted 22 lines changed or added

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