Skip to content

Commit 769bf0c

Browse files
committed
8355515: Clarify the purpose of forcePass() and forceFail() methods
Backport-of: 1a97eb429b520b7c4e625b97553c954d065c00cb
1 parent dbf4f06 commit 769bf0c

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

test/jdk/java/awt/regtesthelpers/PassFailJFrame.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@
150150
* Before returning from {@code awaitAndCheck}, the framework disposes of
151151
* all the windows and frames.
152152
*
153+
* <p id="forcePassAndFail">
154+
* For semi-automatic tests, use {@code forcePass} or
155+
* {@code forceFail} methods to forcibly pass or fail the test
156+
* when it's determined that the required conditions are already met
157+
* or cannot be met correspondingly.
158+
* These methods release {@code awaitAndCheck}, and
159+
* the test will complete successfully or fail.
160+
* <p>
161+
* Refer to examples of using these methods in the description of the
162+
* {@link #forcePass() forcePass} and {@link #forceFail() forceFail} methods.
163+
*
153164
* <h2 id="sampleManualTest">Sample Manual Test</h2>
154165
* A simple test would look like this:
155166
* {@snippet id='sampleManualTestCode' lang='java':
@@ -1310,14 +1321,34 @@ public static void forcePass() {
13101321
}
13111322

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

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

0 commit comments

Comments
 (0)