"Fossies" - the Fresh Open Source Software Archive  

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

TestTemplateTestDescriptor.java  (junit5-r5.3.2):TestTemplateTestDescriptor.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;
skipping to change at line 24 skipping to change at line 24
import static org.apiguardian.api.API.Status.INTERNAL; import static org.apiguardian.api.API.Status.INTERNAL;
import static org.junit.jupiter.engine.descriptor.ExtensionUtils.populateNewExte nsionRegistryFromExtendWithAnnotation; import static org.junit.jupiter.engine.descriptor.ExtensionUtils.populateNewExte nsionRegistryFromExtendWithAnnotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.apiguardian.api.API; import org.apiguardian.api.API;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestInstances;
import org.junit.jupiter.api.extension.TestTemplateInvocationContext; import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext; import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext;
import org.junit.jupiter.engine.extension.ExtensionRegistry; import org.junit.jupiter.engine.extension.ExtensionRegistry;
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.UniqueId; import org.junit.platform.engine.UniqueId;
/** /**
* {@link TestDescriptor} for {@link org.junit.jupiter.api.TestTemplate @TestTem plate} * {@link TestDescriptor} for {@link org.junit.jupiter.api.TestTemplate @TestTem plate}
* methods. * methods.
* *
* @since 5.0 * @since 5.0
*/ */
@API(status = INTERNAL, since = "5.0") @API(status = INTERNAL, since = "5.0")
public class TestTemplateTestDescriptor extends MethodBasedTestDescriptor implem ents Filterable { public class TestTemplateTestDescriptor extends MethodBasedTestDescriptor implem ents Filterable {
private final DynamicDescendantFilter dynamicDescendantFilter = new Dynam icDescendantFilter(); private final DynamicDescendantFilter dynamicDescendantFilter = new Dynam icDescendantFilter();
public TestTemplateTestDescriptor(UniqueId uniqueId, Class<?> testClass, public TestTemplateTestDescriptor(UniqueId uniqueId, Class<?> testClass,
Method templateMethod) { Method templateMethod,
super(uniqueId, testClass, templateMethod); JupiterConfiguration configuration) {
super(uniqueId, testClass, templateMethod, configuration);
} }
// --- Filterable ------------------------------------------------------- --- // --- Filterable ------------------------------------------------------- ---
@Override @Override
public DynamicDescendantFilter getDynamicDescendantFilter() { public DynamicDescendantFilter getDynamicDescendantFilter() {
return dynamicDescendantFilter; return dynamicDescendantFilter;
} }
// --- TestDescriptor --------------------------------------------------- --- // --- TestDescriptor --------------------------------------------------- ---
skipping to change at line 74 skipping to change at line 77
} }
// --- Node ------------------------------------------------------------- --- // --- Node ------------------------------------------------------------- ---
@Override @Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContex t context) throws Exception { public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContex t context) throws Exception {
ExtensionRegistry registry = populateNewExtensionRegistryFromExte ndWithAnnotation( ExtensionRegistry registry = populateNewExtensionRegistryFromExte ndWithAnnotation(
context.getExtensionRegistry(), getTestMethod()); context.getExtensionRegistry(), getTestMethod());
// The test instance should be properly maintained by the enclosi ng class's ExtensionContext. // The test instance should be properly maintained by the enclosi ng class's ExtensionContext.
Object testInstance = context.getExtensionContext().getTestInstan ce().orElse(null); TestInstances testInstances = context.getExtensionContext().getTe stInstances().orElse(null);
ExtensionContext extensionContext = new TestTemplateExtensionCont ext(context.getExtensionContext(), ExtensionContext extensionContext = new TestTemplateExtensionCont ext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfigur ationParameters(), testInstance); context.getExecutionListener(), this, context.getConfigur ation(), testInstances);
// @formatter:off // @formatter:off
return context.extend() return context.extend()
.withExtensionRegistry(registry) .withExtensionRegistry(registry)
.withExtensionContext(extensionContext) .withExtensionContext(extensionContext)
.build(); .build();
// @formatter:on // @formatter:on
} }
@Override @Override
skipping to change at line 126 skipping to change at line 129
return Preconditions.notEmpty(providers, return Preconditions.notEmpty(providers,
() -> String.format("You must register at least one %s th at supports @TestTemplate method [%s]", () -> String.format("You must register at least one %s th at supports @TestTemplate method [%s]",
TestTemplateInvocationContextProvider.class.getSi mpleName(), getTestMethod())); TestTemplateInvocationContextProvider.class.getSi mpleName(), getTestMethod()));
} }
private Optional<TestDescriptor> createInvocationTestDescriptor(TestTempl ateInvocationContext invocationContext, private Optional<TestDescriptor> createInvocationTestDescriptor(TestTempl ateInvocationContext invocationContext,
int index) { int index) {
UniqueId uniqueId = getUniqueId().append(TestTemplateInvocationTe stDescriptor.SEGMENT_TYPE, "#" + index); UniqueId uniqueId = getUniqueId().append(TestTemplateInvocationTe stDescriptor.SEGMENT_TYPE, "#" + index);
if (getDynamicDescendantFilter().test(uniqueId)) { if (getDynamicDescendantFilter().test(uniqueId)) {
return Optional.of(new TestTemplateInvocationTestDescript or(uniqueId, getTestClass(), getTestMethod(), return Optional.of(new TestTemplateInvocationTestDescript or(uniqueId, getTestClass(), getTestMethod(),
invocationContext, index)); invocationContext, index, configuration));
} }
return Optional.empty(); return Optional.empty();
} }
private void execute(DynamicTestExecutor dynamicTestExecutor, TestDescrip tor testDescriptor) { private void execute(DynamicTestExecutor dynamicTestExecutor, TestDescrip tor testDescriptor) {
addChild(testDescriptor); addChild(testDescriptor);
dynamicTestExecutor.execute(testDescriptor); dynamicTestExecutor.execute(testDescriptor);
} }
private void validateWasAtLeastInvokedOnce(int invocationIndex) { private void validateWasAtLeastInvokedOnce(int invocationIndex) {
 End of changes. 7 change blocks. 
7 lines changed or deleted 10 lines changed or added

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