From 6d3945018f332ec9c82077d5cd9cebb1fdb895a3 Mon Sep 17 00:00:00 2001 From: RalfBarkow Date: Thu, 6 Jun 2024 20:02:33 +0200 Subject: [PATCH] feat: Skip GUI-related tests when no X11 DISPLAY is set - Added check for DISPLAY environment variable in SwingAppWithJavaFXAndJEditorPaneTest. - Throw SkipException to skip GUI tests if DISPLAY is not set. - Ensures GUI tests are only run in environments with an available display. --- .../swing/SwingAppWithJavaFXAndJEditorPaneTest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test/java/playground/swing/SwingAppWithJavaFXAndJEditorPaneTest.java b/src/test/java/playground/swing/SwingAppWithJavaFXAndJEditorPaneTest.java index 0828c2f3..c39ad0e6 100644 --- a/src/test/java/playground/swing/SwingAppWithJavaFXAndJEditorPaneTest.java +++ b/src/test/java/playground/swing/SwingAppWithJavaFXAndJEditorPaneTest.java @@ -1,5 +1,6 @@ package playground.swing; +import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -19,6 +20,11 @@ public class SwingAppWithJavaFXAndJEditorPaneTest { @BeforeClass public void setUp() { + + if (System.getenv("DISPLAY") == null) { + throw new SkipException("Skipping GUI tests as no DISPLAY is set"); + } + // Initialize the application components frame = new JFrame("Swing and JavaFX Application"); panel = new JPanel();