diff --git a/Hitori/pom.xml b/Hitori/pom.xml
index a65b7f7..e44b179 100644
--- a/Hitori/pom.xml
+++ b/Hitori/pom.xml
@@ -14,4 +14,25 @@
UTF-8
-
\ No newline at end of file
+
+
+
+ org.assertj
+ assertj-swing
+ 3.17.1
+ test
+
+
+ junit
+ junit
+ 4.13.1
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ 5.8.1
+ test
+
+
+
diff --git a/Hitori/src/main/java/PR2/HitoriSpiel/GUI/StartMenu.java b/Hitori/src/main/java/PR2/HitoriSpiel/GUI/StartMenu.java
index 3544d23..7d88a1c 100644
--- a/Hitori/src/main/java/PR2/HitoriSpiel/GUI/StartMenu.java
+++ b/Hitori/src/main/java/PR2/HitoriSpiel/GUI/StartMenu.java
@@ -13,21 +13,28 @@ public class StartMenu extends JPanel {
JButton continueButton = createButton("Spiel fortsetzen", 200, 30);
JButton selectBoardButton = createButton("Spielfeld aussuchen", 200, 30);
JButton randomBoardButton = createButton("Zufälliges Spielfeld", 200, 30);
- JButton highscoreButton = createButton("Highscore anzeigen", 200, 30);
+ JButton highscorelistButton = createButton("Highscoreliste anzeigen", 200, 30);
JButton exitButton = createButton("Spiel beenden", 200, 30);
+ // Namen für AssertJ-Swing setzen
+ continueButton.setName("continueButton");
+ selectBoardButton.setName("selectBoardButton");
+ randomBoardButton.setName("randomBoardButton");
+ highscorelistButton.setName("highscorelistButton");
+ exitButton.setName("exitButton");
+
// ActionListener hinzufügen
continueButton.addActionListener(e -> showMessage("Spiel fortsetzen wird implementiert."));
selectBoardButton.addActionListener(e -> showMessage("Spielfeld auswählen wird implementiert."));
randomBoardButton.addActionListener(e -> showMessage("Zufälliges Spielfeld wird gestartet."));
- highscoreButton.addActionListener(e -> showMessage("Highscore-Liste wird angezeigt."));
+ highscorelistButton.addActionListener(e -> showMessage("Highscore-Liste wird angezeigt."));
exitButton.addActionListener(e -> System.exit(0));
// Buttons zum Panel hinzufügen
this.add(continueButton);
this.add(selectBoardButton);
this.add(randomBoardButton);
- this.add(highscoreButton);
+ this.add(highscorelistButton);
this.add(exitButton);
}
diff --git a/Hitori/src/test/java/GUI/StartMenuTest.java b/Hitori/src/test/java/GUI/StartMenuTest.java
new file mode 100644
index 0000000..3de0310
--- /dev/null
+++ b/Hitori/src/test/java/GUI/StartMenuTest.java
@@ -0,0 +1,53 @@
+package GUI;
+
+import PR2.HitoriSpiel.GUI.StartMenu;
+import org.assertj.swing.edt.GuiActionRunner;
+import org.assertj.swing.fixture.FrameFixture;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import javax.swing.*;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class StartMenuTest {
+
+ private FrameFixture window;
+
+ @BeforeEach
+ public void setUp() {
+ JFrame frame = GuiActionRunner.execute(() -> {
+ JFrame testFrame = new JFrame();
+ testFrame.add(new StartMenu(testFrame));
+ testFrame.pack();
+ testFrame.setVisible(true);
+ return testFrame;
+ });
+ window = new FrameFixture(frame);
+ }
+
+ @AfterEach
+ public void tearDown() {
+ window.cleanUp();
+ }
+
+ @Test
+ public void testButtonsExist() {
+ // Buttons über ihre Namen finden und testen
+ assertThat(window.button("continueButton")).isNotNull();
+ assertThat(window.button("selectBoardButton")).isNotNull();
+ assertThat(window.button("randomBoardButton")).isNotNull();
+ assertThat(window.button("highscorelistButton")).isNotNull();
+ assertThat(window.button("exitButton")).isNotNull();
+ }
+
+ @Test
+ public void testButtonActions() {
+ window.button("continueButton").click();
+ window.button("selectBoardButton").click();
+ window.button("randomBoardButton").click();
+ window.button("highscorelistButton").click();
+ window.button("exitButton").click();
+ }
+}