forked from junit-team/junit5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create TestExecutionControl to stop test
Issue: junit-team#1880 Signed-off-by: yongjunhong <kevin0928@naver.com>
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
junit-platform-launcher/src/main/java/org/junit/platform/launcher/TestExecutionControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2015-2024 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.platform.launcher; | ||
|
||
/** | ||
* Interface for controlling the execution of tests. | ||
*/ | ||
public interface TestExecutionControl { | ||
|
||
/** | ||
* Cancels the ongoing test execution. | ||
* | ||
* <p>This method initiates a graceful shutdown of the test execution process. | ||
* It allows currently running tests to complete but prevents any new tests | ||
* from starting. | ||
*/ | ||
void cancel(); | ||
|
||
/** | ||
* Forcefully terminates the test execution. | ||
* | ||
* <p>This method immediately stops all running tests and terminates the | ||
* test execution process. It should be used with caution as it may leave | ||
* the system in an inconsistent state. | ||
*/ | ||
void forceTerminate(); | ||
|
||
/** | ||
* Sets and returns the failure threshold for stopping test execution. | ||
* | ||
* <p>This method sets the number of test failures after which the remaining test execution | ||
* will be automatically stopped. Setting this to a positive number will stop the test execution | ||
* after the specified number of failures has been encountered. This is particularly | ||
* useful for handling potentially flaky tests or for optimizing test suite execution time. | ||
* | ||
* <p>For example, if you suspect that some tests in your suite might be flaky, | ||
* calling {@code failureThreshold(1)} would stop the execution after the first | ||
* failure, as this is sufficient to indicate a potential issue. Alternatively, | ||
* you can set the threshold to a number greater than 1 depending on your specific | ||
* testing requirements and tolerance for failures. | ||
* | ||
* <p>Setting this to {@link Integer#MAX_VALUE} signals that no failure | ||
* threshold will be applied, meaning that all tests in the suite will be executed | ||
* regardless of how many failures occur. | ||
* | ||
* @param failureThreshold the failure threshold to be set | ||
* @return the set failure threshold | ||
*/ | ||
int failureThreshold(int failureThreshold); | ||
|
||
} |