Class AbstractHeadlessMonocleExtension
- java.lang.Object
-
- org.testfx.api.FxRobot
-
- com.github.actionfx.testing.junit5.AbstractHeadlessMonocleExtension
-
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor,org.junit.jupiter.api.extension.ParameterResolver,org.junit.jupiter.api.extension.TestInstanceFactory,org.junit.jupiter.api.extension.TestInstancePostProcessor,org.testfx.api.FxRobotInterface
- Direct Known Subclasses:
FxThreadForAllMonocleExtension,FxThreadForEachMonocleExtension
public abstract class AbstractHeadlessMonocleExtension extends org.testfx.api.FxRobot implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.TestInstancePostProcessor, org.junit.jupiter.api.extension.ParameterResolver, org.junit.jupiter.api.extension.TestInstanceFactory, org.junit.jupiter.api.extension.InvocationInterceptorExtension to TestFX'sApplicationExtensionthat sets the test platform "Monocle" to "headless".This base class provides routines to control the creation and shutdown of the JavaFX application and thread explicetly.
This extension is abstract and allows derived classes to explicitly control the lifecycle of the JavaFX application and thread. Originally, TestFX's
ApplicationExtensionstarts the JavaFX application and thread before the test method execution takes place. This behavior however causes issues with test fixtures that require a JavaFX thread and application also outside the test method. When using Spring e.g., Spring might want to instantiate a bean within the JavaFX thread, which would not be possible by plainly using theApplicationExtesion.Additionally, the initialization of the Java toolkit must happen way before the instantiation of the class under test, because it can be that there are nodes instantiated outside of the test method itself. This will fail, if the toolkit is not yet initialized.
- Author:
- MartinKoster
-
-
Constructor Summary
Constructors Constructor Description AbstractHeadlessMonocleExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context)voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context)java.lang.ObjectcreateTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)voidinterceptTestMethod(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)voidpostProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context)java.lang.ObjectresolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)protected voidstartJavaFxApplication()Starts the JavaFX application thread.protected voidstopJavaFxApplication()Stops the JavaFX application thread.booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)-
Methods inherited from class org.testfx.api.FxRobot
bounds, bounds, bounds, bounds, bounds, bounds, bounds, bounds, bounds, capture, capture, capture, capture, capture, capture, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, closeCurrentWindow, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, drag, drag, drag, drag, drag, drag, drag, drag, drag, drag, drag, drop, dropBy, dropTo, dropTo, dropTo, dropTo, dropTo, dropTo, dropTo, dropTo, dropTo, dropTo, eraseText, from, from, from, fromAll, interact, interact, interactNoWait, interactNoWait, interrupt, interrupt, listTargetWindows, listWindows, lookup, lookup, lookup, moveBy, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, offset, offset, offset, offset, offset, offset, offset, offset, offset, point, point, point, point, point, point, point, point, point, press, press, push, push, release, release, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, robotContext, rootNode, rootNode, rootNode, scroll, scroll, scroll, scroll, scroll, sleep, sleep, targetPos, targetWindow, targetWindow, targetWindow, targetWindow, targetWindow, targetWindow, targetWindow, targetWindow, type, type, window, window, window, window, window, window, write, write, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.testfx.api.FxRobotInterface
clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, clickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, doubleClickOn, moveBy, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, offset, offset, offset, offset, offset, offset, offset, offset, offset, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn, rightClickOn
-
-
-
-
Method Detail
-
createTestInstance
public java.lang.Object createTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)- Specified by:
createTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstanceFactory
-
postProcessTestInstance
public void postProcessTestInstance(java.lang.Object testInstance, org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception- Specified by:
postProcessTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstancePostProcessor- Throws:
java.lang.Exception
-
startJavaFxApplication
protected void startJavaFxApplication()
Starts the JavaFX application thread. This method must be called AFTER the test instance is internally created.
-
stopJavaFxApplication
protected void stopJavaFxApplication()
Stops the JavaFX application thread.
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
java.lang.Exception
-
interceptTestMethod
public 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- Specified by:
interceptTestMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
java.lang.Throwable
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)- Specified by:
supportsParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
resolveParameter
public java.lang.Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)- Specified by:
resolveParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
java.lang.Exception
-
-