How can you make an assumption that checks if a test is executed in an interactive session?
FEST robot clicks and such are ignored on the CI server now since the session is not interactive, but I don't want to hard-codedly @Disable them. I would rather execute some assumption that tests if my BasicRobot can do anything at all. I refer to org.fest.swing.core.BasicRobot / org.assertj.swing.core.BasicRobot.
I would rather avoid displaying an auxiliary Window @BeforeEach (or even @BeforeAll).
This, on the other hand, relies on an initial pointer location which makes it a bit fragile.
@BeforeEach
void testRobot() {
PointerInfo initialPointerInfo = MouseInfo.getPointerInfo();
Point initialLocation = initialPointerInfo.getLocation();
robot.moveMouse(initialLocation.x + 5, initialLocation.y + 5);
PointerInfo subsequentPointerInfo = MouseInfo.getPointerInfo();
Point subsequentLocation = subsequentPointerInfo.getLocation();
assumeFalse(Objects.equals(initialLocation, subsequentLocation), "Robot commands ignored. Non-interactive session?");
}
Please note it is not about headless / not headless (the server does have a graphic environment).
Java 8.