junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/AfterAllCallback.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 org.apiguardian.api.API; |
| 16 | |
| 17 | /** |
| 18 | * {@code AfterAllCallback} defines the API for {@link Extension Extensions} |
| 19 | * that wish to provide additional behavior to test containers <strong>once</strong> |
| 20 | * after all tests in the container have been executed. |
| 21 | * |
| 22 | * <p>Concrete implementations often implement {@link BeforeAllCallback} as well. |
| 23 | * |
| 24 | * <p>Extensions that implement {@code AfterAllCallback} must be registered at |
| 25 | * the class level. |
| 26 | * |
| 27 | * <h2>Constructor Requirements</h2> |
| 28 | * |
| 29 | * <p>Consult the documentation in {@link Extension} for details on |
| 30 | * constructor requirements. |
| 31 | * |
| 32 | * <h2>Wrapping Behavior</h2> |
| 33 | * |
| 34 | * <p>JUnit Jupiter guarantees <em>wrapping behavior</em> for multiple |
| 35 | * registered extensions that implement lifecycle callbacks such as |
| 36 | * {@link BeforeAllCallback}, {@link AfterAllCallback}, |
| 37 | * {@link BeforeEachCallback}, {@link AfterEachCallback}, |
| 38 | * {@link BeforeTestExecutionCallback}, and {@link AfterTestExecutionCallback}. |
| 39 | * |
| 40 | * <p>That means that, given two extensions {@code Extension1} and |
| 41 | * {@code Extension2} with {@code Extension1} registered before |
| 42 | * {@code Extension2}, any "before" callbacks implemented by {@code Extension1} |
| 43 | * are guaranteed to execute before any "before" callbacks implemented by |
| 44 | * {@code Extension2}. Similarly, given the two same two extensions registered |
| 45 | * in the same order, any "after" callbacks implemented by {@code Extension1} |
| 46 | * are guaranteed to execute after any "after" callbacks implemented by |
| 47 | * {@code Extension2}. {@code Extension1} is therefore said to <em>wrap</em> |
| 48 | * {@code Extension2}. |
| 49 | * |
| 50 | * @since 5.0 |
| 51 | * @see org.junit.jupiter.api.AfterAll |
| 52 | * @see BeforeAllCallback |
| 53 | * @see BeforeEachCallback |
| 54 | * @see AfterEachCallback |
| 55 | * @see BeforeTestExecutionCallback |
| 56 | * @see AfterTestExecutionCallback |
| 57 | */ |
| 58 | @FunctionalInterface |
| 59 | @API(status = STABLE, since = "5.0") |
| 60 | public interface AfterAllCallback extends Extension { |
| 61 | |
| 62 | /** |
| 63 | * Callback that is invoked once <em>after</em> all tests in the current |
| 64 | * container. |
| 65 | * |
| 66 | * @param context the current extension context; never {@code null} |
| 67 | */ |
| 68 | void afterAll(ExtensionContext context) throws Exception; |
| 69 | |
| 70 | } |