Skip to content

8355515: Clarify the purpose of forcePass() and forceFail() methods #25091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@
* Before returning from {@code awaitAndCheck}, the framework disposes of
* all the windows and frames.
*
* <p id="forcePassAndFail">
* For semi-automatic tests, use {@code forcePass} or
* {@code forceFail} methods to forcibly pass or fail the test
* when it's determined that the required conditions are already met
* or cannot be met correspondingly.
* These methods release {@code awaitAndCheck}, and
* the test will complete successfully or fail.
* <p>
* Refer to examples of using these methods in the description of the
* {@link #forcePass() forcePass} and {@link #forceFail() forceFail} methods.
*
* <h2 id="sampleManualTest">Sample Manual Test</h2>
* A simple test would look like this:
* {@snippet id='sampleManualTestCode' lang='java':
Expand Down Expand Up @@ -1310,14 +1321,34 @@ public static void forcePass() {
}

/**
* Forcibly fail the test.
* Forcibly fail the test.
* <p>
* Use this method in semi-automatic tests when
* it is determined that the conditions for passing the test cannot be met.
* <p>
* <strong>Do not use</strong> this method in cases where a resource is unavailable or a
* feature isn't supported, throw {@code jtreg.SkippedException} instead.
*
* <p>A sample usage can be found in
* <a href="https://github.com/openjdk/jdk/blob/0844745e7bd954a96441365f8010741ec1c29dbf/test/jdk/javax/swing/JScrollPane/AcceleratedWheelScrolling/HorizScrollers.java#L180">{@code
* HorizScrollers.java}</a>
*/
public static void forceFail() {
forceFail("forceFail called");
}

/**
* Forcibly fail the test and provide a reason.
* Forcibly fail the test and provide a reason.
* <p>
* Use this method in semi-automatic tests when
* it is determined that the conditions for passing the test cannot be met.
* <p>
* <strong>Do not use</strong> this method in cases where a resource is unavailable or a
* feature isn't supported, throw {@code jtreg.SkippedException} instead.
*
* <p>A sample usage can be found in
* <a href="https://github.com/openjdk/jdk/blob/7283c8b075aa289dbb9cb80f6937b3349c8d4769/test/jdk/java/awt/FileDialog/SaveFileNameOverrideTest.java#L86">{@code
* SaveFileNameOverrideTest.java}</a>
*
* @param reason the reason why the test is failed
*/
Expand Down