org.junit.jupiter.engine.descriptor.MethodExtensionContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-jupiter-engine Show documentation
Show all versions of junit-jupiter-engine Show documentation
Module "junit-jupiter-engine" of JUnit 5.
/*
* Copyright 2015-2022 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/
package org.junit.jupiter.engine.descriptor;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
import java.util.Optional;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.extension.ExecutableInvoker;
import org.junit.jupiter.api.extension.ExtensionContext;
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.support.hierarchical.Node;
import org.junit.platform.engine.support.hierarchical.ThrowableCollector;
/**
* @since 5.0
*/
final class MethodExtensionContext extends AbstractExtensionContext {
private final ThrowableCollector throwableCollector;
private TestInstances testInstances;
MethodExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
TestMethodTestDescriptor testDescriptor, JupiterConfiguration configuration,
ThrowableCollector throwableCollector, ExecutableInvoker executableInvoker) {
super(parent, engineExecutionListener, testDescriptor, configuration, executableInvoker);
this.throwableCollector = throwableCollector;
}
@Override
public Optional getElement() {
return Optional.of(getTestDescriptor().getTestMethod());
}
@Override
public Optional> getTestClass() {
return Optional.of(getTestDescriptor().getTestClass());
}
@Override
public Optional getTestInstanceLifecycle() {
return getParent().flatMap(ExtensionContext::getTestInstanceLifecycle);
}
@Override
public Optional
© 2015 - 2024 Weber Informatics LLC | Privacy Policy