Debian Codegraph @

junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/TestInstanceFactoryContext.java

raw symbols SCIP
1 /*
2 * Copyright 2015-2024 the original author or authors.
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v2.0 which
6 * accompanies this distribution and is available at
7 *
8 * https://www.eclipse.org/legal/epl-v20.html
9 */
10
11 package org.junit.jupiter.api.extension;
12
13 import static org.apiguardian.api.API.Status.STABLE;
14
15 import java.util.Optional;
16
17 import org.apiguardian.api.API;
18
19 /**
20 * {@code TestInstanceFactoryContext} encapsulates the <em>context</em> in which
21 * a {@linkplain #getTestClass test class} is to be instantiated by a
22 * {@link TestInstanceFactory}.
23 *
24 * @since 5.3
25 * @see TestInstanceFactory
26 */
27 @API(status = STABLE, since = "5.7")
28 public interface TestInstanceFactoryContext {
29
30 /**
31 * Get the test class for this context.
32 *
33 * @return the test class to be instantiated; never {@code null}
34 */
35 Class<?> getTestClass();
36
37 /**
38 * Get the instance of the outer class, if available.
39 *
40 * <p>The returned {@link Optional} will be <em>empty</em> unless the
41 * current {@linkplain #getTestClass() test class} is a
42 * {@link org.junit.jupiter.api.Nested @Nested} test class.
43 *
44 * @return an {@code Optional} containing the outer test instance; never
45 * {@code null} but potentially empty
46 * @see org.junit.jupiter.api.Nested
47 */
48 Optional<Object> getOuterInstance();
49
50 }