Skip to content

Commit c46b54a

Browse files
authored
[wpilibj] Use non-global NetworkTableInstance in alert test (#8265)
1 parent 7290766 commit c46b54a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

wpilibj/src/test/java/edu/wpi/first/wpilibj/AlertTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
import org.junit.jupiter.api.parallel.ResourceLock;
2424

2525
class AlertTest {
26-
String m_groupName;
26+
private NetworkTableInstance m_inst;
27+
private String m_groupName;
2728

2829
@BeforeEach
2930
void setup(TestInfo info) {
3031
m_groupName = "AlertTest_" + info.getDisplayName();
32+
33+
m_inst = NetworkTableInstance.create();
34+
SmartDashboard.setNetworkTableInstance(m_inst);
3135
}
3236

3337
@AfterEach
@@ -36,6 +40,9 @@ void checkClean() {
3640
assertEquals(0, getActiveAlerts(AlertType.kError).length);
3741
assertEquals(0, getActiveAlerts(AlertType.kWarning).length);
3842
assertEquals(0, getActiveAlerts(AlertType.kInfo).length);
43+
44+
m_inst.close();
45+
SmartDashboard.setNetworkTableInstance(NetworkTableInstance.getDefault());
3946
}
4047

4148
private String getSubtableName(Alert.AlertType type) {
@@ -52,7 +59,7 @@ private String getSubtableName(Alert.AlertType type) {
5259
}
5360

5461
private StringArraySubscriber getSubscriberForType(Alert.AlertType type) {
55-
return NetworkTableInstance.getDefault()
62+
return m_inst
5663
.getStringArrayTopic("/SmartDashboard/" + m_groupName + "/" + getSubtableName(type))
5764
.subscribe(new String[] {});
5865
}

0 commit comments

Comments
 (0)