From c46b54a523f07c560837ff1470fa0ce51104ed14 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 29 Sep 2025 20:45:37 -0400 Subject: [PATCH] [wpilibj] Use non-global NetworkTableInstance in alert test (#8265) --- .../test/java/edu/wpi/first/wpilibj/AlertTest.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wpilibj/src/test/java/edu/wpi/first/wpilibj/AlertTest.java b/wpilibj/src/test/java/edu/wpi/first/wpilibj/AlertTest.java index 79e4bb0f88..39625b4927 100644 --- a/wpilibj/src/test/java/edu/wpi/first/wpilibj/AlertTest.java +++ b/wpilibj/src/test/java/edu/wpi/first/wpilibj/AlertTest.java @@ -23,11 +23,15 @@ import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.parallel.ResourceLock; class AlertTest { - String m_groupName; + private NetworkTableInstance m_inst; + private String m_groupName; @BeforeEach void setup(TestInfo info) { m_groupName = "AlertTest_" + info.getDisplayName(); + + m_inst = NetworkTableInstance.create(); + SmartDashboard.setNetworkTableInstance(m_inst); } @AfterEach @@ -36,6 +40,9 @@ class AlertTest { assertEquals(0, getActiveAlerts(AlertType.kError).length); assertEquals(0, getActiveAlerts(AlertType.kWarning).length); assertEquals(0, getActiveAlerts(AlertType.kInfo).length); + + m_inst.close(); + SmartDashboard.setNetworkTableInstance(NetworkTableInstance.getDefault()); } private String getSubtableName(Alert.AlertType type) { @@ -52,7 +59,7 @@ class AlertTest { } private StringArraySubscriber getSubscriberForType(Alert.AlertType type) { - return NetworkTableInstance.getDefault() + return m_inst .getStringArrayTopic("/SmartDashboard/" + m_groupName + "/" + getSubtableName(type)) .subscribe(new String[] {}); }