diff --git a/build.gradle b/build.gradle index 75a518ea61d8..5c0329e610ec 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,8 @@ // For more details take a look at the Java Quickstart chapter in the Gradle // user guide available at http://gradle.org/docs/4.6/userguide/tutorial_java_projects.html +import org.gradle.api.tasks.testing.logging.TestLogEvent + plugins { id 'java' id 'jacoco' @@ -117,12 +119,14 @@ allTests.dependsOn nonGuiTests test { systemProperty 'testfx.setup.timeout', '60000' - // Prints the currently running test's name in the CI's build log, - // so that we can check if tests are being silently skipped or - // stalling the build. - if (System.env.'CI') { - beforeTest { descriptor -> - logger.lifecycle("Running test: ${descriptor}") + testLogging { + events TestLogEvent.FAILED, TestLogEvent.SKIPPED + + // Prints the currently running test's name in the CI's build log, + // so that we can check if tests are being silently skipped or + // stalling the build. + if (System.env.'CI') { + events << TestLogEvent.STARTED } } diff --git a/src/test/java/guitests/GuiRobot.java b/src/test/java/guitests/GuiRobot.java index d8a301aa41e7..f4e0700b22f7 100644 --- a/src/test/java/guitests/GuiRobot.java +++ b/src/test/java/guitests/GuiRobot.java @@ -39,6 +39,13 @@ public void pauseForHuman() { sleep(PAUSE_FOR_HUMAN_DELAY_MILLISECONDS); } + /** + * Returns true if tests are run in headless mode. + */ + public boolean isHeadlessMode() { + return isHeadlessMode; + } + /** * Waits for {@code event} to be true by {@code DEFAULT_WAIT_FOR_EVENT_TIMEOUT_MILLISECONDS} milliseconds. * diff --git a/src/test/java/seedu/address/ui/HelpWindowTest.java b/src/test/java/seedu/address/ui/HelpWindowTest.java index 461f5bba2eae..0dfb9842284c 100644 --- a/src/test/java/seedu/address/ui/HelpWindowTest.java +++ b/src/test/java/seedu/address/ui/HelpWindowTest.java @@ -3,6 +3,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; import static seedu.address.ui.HelpWindow.USERGUIDE_FILE_PATH; import java.net.URL; @@ -46,8 +47,12 @@ public void isShowing_helpWindowIsHiding_returnsFalse() { } @Test - public void focus_helpWindowNotFocused_focused() { + public void focus_helpWindowNotFocused_focused() throws Exception { + assumeFalse("Test skipped in headless mode: Window focus behavior is buggy.", guiRobot.isHeadlessMode()); guiRobot.interact(helpWindow::show); + + // Focus on another stage to remove focus from the helpWindow + FxToolkit.setupStage(Stage::requestFocus); assertFalse(helpWindow.getRoot().isFocused()); guiRobot.interact(helpWindow::focus);