From 47b0ff9bed3a5ccd12c1d20c962dd02d4cba71b4 Mon Sep 17 00:00:00 2001 From: Besmir Beqiri Date: Thu, 17 Oct 2024 22:02:54 +0200 Subject: [PATCH] Exclude `media-recorder` tests when running on CI --- .github/workflows/main.yml | 1 + jpro-media/build.gradle | 13 +++++++++++++ .../media/test/MediaRecorderTests.java | 19 +++---------------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 90269849..96db5277 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,6 +5,7 @@ on: [push] env: DISPLAY: ":99" XVFB_PARAMS: "-screen 0 1920x1080x24" + RUNNING_ON_CI: true jobs: builds: diff --git a/jpro-media/build.gradle b/jpro-media/build.gradle index ea5e4d70..849d04f1 100644 --- a/jpro-media/build.gradle +++ b/jpro-media/build.gradle @@ -31,6 +31,19 @@ test { "--add-exports", "javafx.graphics/com.sun.javafx.util=org.testfx.monocle", "--add-exports", "javafx.graphics/com.sun.glass.ui=org.testfx.monocle" ] + + // Check if the RUNNING_ON_CI environment variable is set to 'true' + def runningOnCi = System.getenv('RUNNING_ON_CI') == 'true' + + // Pass the environment variable to the test JVM as a system property + systemProperty 'RUNNING_ON_CI', runningOnCi + + // Exclude media tests when running on CI + if (runningOnCi) { + filter { + excludeTags 'media-recorder' + } + } } javadoc { diff --git a/jpro-media/src/test/java/one/jpro/platform/media/test/MediaRecorderTests.java b/jpro-media/src/test/java/one/jpro/platform/media/test/MediaRecorderTests.java index 7a4ef6f3..e64721f6 100644 --- a/jpro-media/src/test/java/one/jpro/platform/media/test/MediaRecorderTests.java +++ b/jpro-media/src/test/java/one/jpro/platform/media/test/MediaRecorderTests.java @@ -26,7 +26,6 @@ import java.util.concurrent.TimeoutException; import static one.jpro.platform.media.recorder.MediaRecorder.Status; -import static org.junit.jupiter.api.Assumptions.assumeFalse; import static org.testfx.assertions.api.Assertions.assertThat; /** @@ -114,10 +113,9 @@ public void start(Stage stage) { } @Test + @Tag("media-recorder") @Order(1) public void media_recorder_enable(FxRobot robot) throws TimeoutException { - skipTestOnCI(); - log.debug("MediaRecorder => Testing enable functionality..."); log.debug("Click on enable camera button"); robot.clickOn(enableCamButton); // Enable camera (asynchronous operation) @@ -135,10 +133,9 @@ public void media_recorder_enable(FxRobot robot) throws TimeoutException { } @Test + @Tag("media-recorder") @Order(2) public void media_recorder_controls(FxRobot robot) throws TimeoutException { - skipTestOnCI(); - log.debug("MediaRecorder => Testing controls..."); log.debug("Click on enable camera button"); robot.clickOn(enableCamButton); // Enable camera (asynchronous operation) @@ -198,10 +195,9 @@ public void media_recorder_controls(FxRobot robot) throws TimeoutException { } @Test + @Tag("media-recorder") @Order(3) public void media_recorder_stress(FxRobot robot) throws TimeoutException { - skipTestOnCI(); - log.debug("MediaRecorder => Stress test started..."); log.debug("Click on enable camera button"); robot.clickOn(enableCamButton); // Enable camera (asynchronous operation) @@ -266,13 +262,4 @@ private void waitForStatus(Status status, long timeout, TimeUnit timeUnit) throw assertThat(mediaRecorder.getStatus()).isEqualByComparingTo(status); WaitForAsyncUtils.waitForFxEvents(); } - - private void skipTestOnCI() { - final String runningOnCI = System.getenv("RUNNING_ON_CI"); - if (runningOnCI != null && !runningOnCI.isBlank()) { - log.warn("MediaRecorder is not supported on the CI."); - assumeFalse(runningOnCI.equalsIgnoreCase("true"), - "MediaRecorder is not supported on the CI."); - } - } }