public static class JavaFXInterceptorUtils.SelectiveJavaFxInterceptor
extends java.lang.Object
implements org.junit.jupiter.api.extension.InvocationInterceptor
@Test statements are executed
in the JavaFX UI thread. This is (strictly) necessary when testing setter
and/or getter methods of JavaFX classes (ie. Node derived, properties etc).
Example usage:
@ExtendWith(ApplicationExtension.class)
@ExtendWith(SelectiveJavaFxInterceptor.class)
public class SquareButtonTest {
@Start
public void start(Stage stage) {
// usual FX initialisation
// ...
}
@TestFx // forces execution in JavaFX thread
public void testJavaFxThreadSafety() {
// verifies that this test is indeed executed in the JavaFX thread
assertTrue(Platform.isFxApplicationThread());
// perform the regular JavaFX thread safe assertion tests
// ...
}
@Test // explicitly not executed in JavaFX thread;
// for different behaviour use: @ExtendWith(JavaFxInterceptor.class)
public void testNonJavaFx() {
// verifies that this test is not executed within the JavaFX thread
assertFalse(Platform.isFxApplicationThread());
// perform the regular non-JavaFX thread-related assertion tests
// ...
}
}
| Constructor and Description |
|---|
SelectiveJavaFxInterceptor() |
| Modifier and Type | Method and Description |
|---|---|
void |
interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<java.lang.Void> invocation,
org.junit.jupiter.api.extension.ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
org.junit.jupiter.api.extension.ExtensionContext extensionContext) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinterceptAfterAllMethod, interceptAfterEachMethod, interceptBeforeAllMethod, interceptBeforeEachMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestTemplateMethodpublic void interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<java.lang.Void> invocation,
org.junit.jupiter.api.extension.ReflectiveInvocationContext<java.lang.reflect.Method> invocationContext,
org.junit.jupiter.api.extension.ExtensionContext extensionContext)
throws java.lang.Throwable
interceptTestMethod in interface org.junit.jupiter.api.extension.InvocationInterceptorjava.lang.Throwable