You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With throwing a SkipException in a TestNG Test it is indicated that this test should be skipped because of not met prerequisites.
In JUnit Jupiter the same is achievable with the Assumptions API.
importjdk.test.lib.Platform;
importorg.testng.SkipException;
importorg.testng.annotations.Test;
publicclassCommandLineNegativeTest {
@Test(dataProvider = "directoryOptions")
publicvoidtestRootNotReadable(Stringopt) throwsThrowable {
if (Platform.isWindows()) {
// Not applicable to Windows. Reason: cannot revoke an owner's read// access to a directory that was created by that ownerthrownewSkipException("cannot run on Windows");
}
//...
}
}
JUnit Jupiter
This test is relatively easy to migrate with the Assumptions API.
importjdk.test.lib.Platform;
importorg.testng.SkipException;
importorg.testng.annotations.Test;
publicclassCommandLineNegativeTest {
@Test(dataProvider = "directoryOptions")
publicvoidtestRootNotReadable(Stringopt) throwsThrowable {
// Not applicable to Windows. Reason: cannot revoke an owner's read// access to a directory that was created by that ownerAssumptions.assumeFalse(Platform.isWindows(), "cannot run on Windows");
//...
}
}
Remarks
Usually the block where a SkipException is thrown is guarded by a boolean expression in an if.
This exception can be reused but in the assumeFalse.
It is important to flip the semantics here!
The text was updated successfully, but these errors were encountered:
With throwing a SkipException in a TestNG Test it is indicated that this test should be skipped because of not met prerequisites.
In JUnit Jupiter the same is achievable with the Assumptions API.
TestNG Example
This example is from OpenJDK https://github.com/openjdk/jdk/blob/master/test/jdk/com/sun/net/httpserver/simpleserver/CommandLineNegativeTest.java#L206
JUnit Jupiter
This test is relatively easy to migrate with the Assumptions API.
Remarks
Usually the block where a SkipException is thrown is guarded by a boolean expression in an if.
This exception can be reused but in the assumeFalse.
It is important to flip the semantics here!
The text was updated successfully, but these errors were encountered: