From 948a064d6477548757cb063a0316119d8c8c2bd1 Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Mon, 16 Jan 2023 23:48:42 +0100 Subject: [PATCH] created test for checking if Action is performed after correct Answer is pressed --- src/test/java/game/loadNextQuestionTest.java | 37 +++++++++++++++++++ .../default-testCompile/inputFiles.lst | 1 + 2 files changed, 38 insertions(+) create mode 100644 src/test/java/game/loadNextQuestionTest.java diff --git a/src/test/java/game/loadNextQuestionTest.java b/src/test/java/game/loadNextQuestionTest.java new file mode 100644 index 0000000..33d613c --- /dev/null +++ b/src/test/java/game/loadNextQuestionTest.java @@ -0,0 +1,37 @@ +package game; + +import static org.junit.jupiter.api.Assertions.*; + +import java.awt.event.ActionEvent; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; + +import Gui.GameGui; +import Gui.gui; +@TestInstance(Lifecycle.PER_CLASS) +class loadNextQuestionTest { + gui gui = new gui(); + GameGui gameGui = new GameGui(); + @BeforeAll + void setUp(){ + gui.StartMainMenu(); + gameGui.createGui(); + } + + @Test + public void testCorrectAnswer() { + //arrange + gameGui.questionNr = 0; + loadNextQuestion loadNextQuestion = new loadNextQuestion(); + runGame.splitAns = new String[] {"option1", "option2", "option3", "option4", "1"}; + //act + gameGui.AnswersBtn1.doClick(); + //assert + assertEquals(1, gameGui.questionNr); + + } + +} \ No newline at end of file diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst index 35cd4ce..cd8f159 100644 --- a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -1,4 +1,5 @@ C:\Users\ozan_\MiniGameProject\src\test\java\Gui\ActionHandlerTest.java C:\Users\ozan_\MiniGameProject\src\test\java\Gui\GameGuiTest.java +C:\Users\ozan_\MiniGameProject\src\test\java\game\loadNextQuestionTest.java C:\Users\ozan_\MiniGameProject\src\test\java\game\runGameTest.java C:\Users\ozan_\MiniGameProject\src\test\java\Gui\guiTest.java