From 7d3a0cd47585187ccc93108603384e58104c05fd Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Mon, 16 Jan 2023 23:56:10 +0100 Subject: [PATCH] created test for checking currentQuestionNr value --- src/test/java/Gui/GameGuiTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/Gui/GameGuiTest.java b/src/test/java/Gui/GameGuiTest.java index 1d9f8e9..a91aa6a 100644 --- a/src/test/java/Gui/GameGuiTest.java +++ b/src/test/java/Gui/GameGuiTest.java @@ -4,6 +4,8 @@ import static org.junit.jupiter.api.Assertions.*; import java.awt.GridBagConstraints; import java.awt.Insets; +import java.io.File; +import java.io.FileWriter; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -58,4 +60,20 @@ class GameGuiTest { gameGui.highScore(); assertEquals(expectedHighScore, gameGui.highScore); } + + @Test + public void testCreateShowQuestion() throws Exception{ + + File file; + file = File.createTempFile("temp", ".txt"); + FileWriter writer = new FileWriter(file); + writer.write("1\n"); + writer.write("2\n"); + writer.write("3\n"); + writer.close(); + GameGui.currentQuestion = 1; + gameGui.createShowQuestion(1 ,file.getAbsolutePath()); + assertEquals("Frage 1: 1 Euro", GameGui.CurrentQuestionNrLabel.getText()); + + } }