| 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.io; |
| 12 | |
| 13 | import static org.apiguardian.api.API.Status.EXPERIMENTAL; |
| 14 | |
| 15 | import org.apiguardian.api.API; |
| 16 | |
| 17 | /** |
| 18 | * Enumeration of cleanup modes for {@link TempDir @TempDir}. |
| 19 | * |
| 20 | * <p>When a test with a temporary directory completes, it might be useful in |
| 21 | * some cases to be able to view the contents of the temporary directory used by |
| 22 | * the test. {@code CleanupMode} allows you to control how a {@code TempDir} |
| 23 | * is cleaned up. |
| 24 | * |
| 25 | * @since 5.9 |
| 26 | * @see TempDir |
| 27 | */ |
| 28 | @API(status = EXPERIMENTAL, since = "5.9") |
| 29 | public enum CleanupMode { |
| 30 | |
| 31 | /** |
| 32 | * Use the default cleanup mode. |
| 33 | * |
| 34 | * @see TempDir#DEFAULT_CLEANUP_MODE_PROPERTY_NAME |
| 35 | */ |
| 36 | DEFAULT, |
| 37 | |
| 38 | /** |
| 39 | * Always clean up a temporary directory after the test has completed. |
| 40 | */ |
| 41 | ALWAYS, |
| 42 | |
| 43 | /** |
| 44 | * Only clean up a temporary directory if the test completed successfully. |
| 45 | */ |
| 46 | ON_SUCCESS, |
| 47 | |
| 48 | /** |
| 49 | * Never clean up a temporary directory after the test has completed. |
| 50 | */ |
| 51 | NEVER; |
| 52 | |
| 53 | } |