"Fossies" - the Fresh Open Source Software Archive  

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

MethodExtensionContext.java  (junit5-r5.3.2):MethodExtensionContext.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 java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Optional; import java.util.Optional;
import org.apiguardian.api.API;
import org.junit.jupiter.api.TestInstance.Lifecycle; import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.engine.ConfigurationParameters; import org.junit.jupiter.api.extension.TestInstances;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.platform.engine.EngineExecutionListener; import org.junit.platform.engine.EngineExecutionListener;
import org.junit.platform.engine.support.hierarchical.ThrowableCollector; import org.junit.platform.engine.support.hierarchical.ThrowableCollector;
/** /**
* @since 5.0 * @since 5.0
*/ */
@API(status = INTERNAL, since = "5.0") final class MethodExtensionContext extends AbstractExtensionContext<TestMethodTe
public final class MethodExtensionContext extends AbstractExtensionContext<TestM stDescriptor> {
ethodTestDescriptor> {
private final Object testInstance;
private final ThrowableCollector throwableCollector; private final ThrowableCollector throwableCollector;
public MethodExtensionContext(ExtensionContext parent, EngineExecutionLis private TestInstances testInstances;
tener engineExecutionListener,
TestMethodTestDescriptor testDescriptor, ConfigurationPar
ameters configurationParameters,
Object testInstance, ThrowableCollector throwableCollecto
r) {
super(parent, engineExecutionListener, testDescriptor, configurat MethodExtensionContext(ExtensionContext parent, EngineExecutionListener e
ionParameters); ngineExecutionListener,
TestMethodTestDescriptor testDescriptor, JupiterConfigura
tion configuration,
ThrowableCollector throwableCollector) {
super(parent, engineExecutionListener, testDescriptor, configurat
ion);
this.testInstance = testInstance;
this.throwableCollector = throwableCollector; this.throwableCollector = throwableCollector;
} }
@Override @Override
public Optional<AnnotatedElement> getElement() { public Optional<AnnotatedElement> getElement() {
return Optional.of(getTestDescriptor().getTestMethod()); return Optional.of(getTestDescriptor().getTestMethod());
} }
@Override @Override
public Optional<Class<?>> getTestClass() { public Optional<Class<?>> getTestClass() {
return Optional.of(getTestDescriptor().getTestClass()); return Optional.of(getTestDescriptor().getTestClass());
} }
@Override @Override
public Optional<Lifecycle> getTestInstanceLifecycle() { public Optional<Lifecycle> getTestInstanceLifecycle() {
return getParent().flatMap(ExtensionContext::getTestInstanceLifec ycle); return getParent().flatMap(ExtensionContext::getTestInstanceLifec ycle);
} }
@Override @Override
public Optional<Object> getTestInstance() { public Optional<Object> getTestInstance() {
return Optional.of(this.testInstance); return getTestInstances().map(TestInstances::getInnermostInstance
);
}
@Override
public Optional<TestInstances> getTestInstances() {
return Optional.ofNullable(this.testInstances);
}
void setTestInstances(TestInstances testInstances) {
this.testInstances = testInstances;
} }
@Override @Override
public Optional<Method> getTestMethod() { public Optional<Method> getTestMethod() {
return Optional.of(getTestDescriptor().getTestMethod()); return Optional.of(getTestDescriptor().getTestMethod());
} }
@Override @Override
public Optional<Throwable> getExecutionException() { public Optional<Throwable> getExecutionException() {
return Optional.ofNullable(this.throwableCollector.getThrowable() ); return Optional.ofNullable(this.throwableCollector.getThrowable() );
 End of changes. 9 change blocks. 
20 lines changed or deleted 25 lines changed or added

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