From aa4bc955076dfc2baece261922713d4a3607d582 Mon Sep 17 00:00:00 2001 From: Lewis-Seiden Date: Fri, 12 Jan 2024 20:42:10 -0800 Subject: [PATCH 1/3] added robot init unit test --- .vscode/settings.json | 3 ++- .wpilib/wpilib_preferences.json | 2 +- src/test/java/frc/InitTests.java | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/java/frc/InitTests.java diff --git a/.vscode/settings.json b/.vscode/settings.json index 2f1b9b39..9263d533 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,5 +26,6 @@ }, ], "java.test.defaultConfig": "WPIlibUnitTests", - "java.compile.nullAnalysis.mode": "automatic" + "java.compile.nullAnalysis.mode": "automatic", + "wpilib.skipTests": true } diff --git a/.wpilib/wpilib_preferences.json b/.wpilib/wpilib_preferences.json index 6c78d01a..6534dffe 100644 --- a/.wpilib/wpilib_preferences.json +++ b/.wpilib/wpilib_preferences.json @@ -1,6 +1,6 @@ { "enableCppIntellisense": false, "currentLanguage": "java", - "projectYear": "2024beta", + "projectYear": "2024", "teamNumber": 8033 } \ No newline at end of file diff --git a/src/test/java/frc/InitTests.java b/src/test/java/frc/InitTests.java new file mode 100644 index 00000000..a03b01cd --- /dev/null +++ b/src/test/java/frc/InitTests.java @@ -0,0 +1,26 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import edu.wpi.first.hal.HAL; +import frc.robot.Robot; + +/** Test robot init. */ +public class InitTests { + @BeforeEach + private void setup() { + HAL.initialize(500, 0); + } + + @Test + private void initTest() { + var robot = new Robot(); + robot.startCompetition(); + robot.close(); + } + } From 1b8e46f573247d8673b0a24f4c4f2535511601d8 Mon Sep 17 00:00:00 2001 From: Lewis-Seiden Date: Sat, 13 Jan 2024 04:49:43 +0000 Subject: [PATCH 2/3] run spotless --- src/test/java/frc/InitTests.java | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/test/java/frc/InitTests.java b/src/test/java/frc/InitTests.java index a03b01cd..6afde4c1 100644 --- a/src/test/java/frc/InitTests.java +++ b/src/test/java/frc/InitTests.java @@ -4,23 +4,22 @@ package frc; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import edu.wpi.first.hal.HAL; import frc.robot.Robot; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** Test robot init. */ public class InitTests { - @BeforeEach - private void setup() { - HAL.initialize(500, 0); - } + @BeforeEach + private void setup() { + HAL.initialize(500, 0); + } - @Test - private void initTest() { - var robot = new Robot(); - robot.startCompetition(); - robot.close(); - } + @Test + private void initTest() { + var robot = new Robot(); + robot.startCompetition(); + robot.close(); } +} From 8ec3ef2078dc2f720ee37bf825f7de183dd5882e Mon Sep 17 00:00:00 2001 From: Lewis-Seiden Date: Sat, 13 Jan 2024 11:54:40 -0800 Subject: [PATCH 3/3] rename init check and make properly check for init errors --- simgui.json | 3 ++- src/test/java/frc/InitTests.java | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/simgui.json b/simgui.json index b30b8d3b..af6d403f 100644 --- a/simgui.json +++ b/simgui.json @@ -29,6 +29,7 @@ }, "Clients": { "open": true - } + }, + "visible": true } } diff --git a/src/test/java/frc/InitTests.java b/src/test/java/frc/InitTests.java index a03b01cd..8ce3c54b 100644 --- a/src/test/java/frc/InitTests.java +++ b/src/test/java/frc/InitTests.java @@ -4,23 +4,25 @@ package frc; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import edu.wpi.first.hal.HAL; import frc.robot.Robot; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** Test robot init. */ public class InitTests { - @BeforeEach - private void setup() { - HAL.initialize(500, 0); - } + @BeforeEach + private void setup() { + HAL.initialize(500, 0); + } - @Test - private void initTest() { - var robot = new Robot(); - robot.startCompetition(); - robot.close(); - } + @Test + protected void initializeRobotDoesntThrow() { + assertDoesNotThrow( + () -> { + new Robot().close(); + }); } +}