From 740f7b5206d7859a54b89fc6a5f3912365023c36 Mon Sep 17 00:00:00 2001 From: law39 Date: Thu, 30 Apr 2020 11:26:43 +0100 Subject: [PATCH] Added TestFX TestFX is now setup and ready to use. Junit 4 has been removed. Junit Jupiter (5) is now the only version available. Tests using Junit 4 have been updated to use Jupiter. --- src/Welsh Vocabulary Tutor/pom.xml | 35 ++++++++++++++----- .../src/main/java/module-info.java | 3 +- .../aber/cs22120/group20/test/JSONTest.java | 15 ++++---- .../test/TranslationControllerTest.java | 1 - 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/pom.xml b/src/Welsh Vocabulary Tutor/pom.xml index bb63d70..4984cc5 100644 --- a/src/Welsh Vocabulary Tutor/pom.xml +++ b/src/Welsh Vocabulary Tutor/pom.xml @@ -20,20 +20,37 @@ javafx-fxml 11 - - org.junit.jupiter - junit-jupiter - 5.4.2 - + + + + + com.fasterxml.jackson.core jackson-databind 2.9.4 + + + + + + - junit - junit - RELEASE + org.junit.jupiter + junit-jupiter-api + 5.5.2 + test + + + org.testfx + testfx-junit5 + 4.0.16-alpha + + + org.junit.jupiter + junit-jupiter-api + 5.5.2 compile @@ -52,7 +69,7 @@ javafx-maven-plugin 0.0.1 - uk.ac.aber.cs22120.group20.Application + uk.ac.aber.cs22120.group20.javafx.Application diff --git a/src/Welsh Vocabulary Tutor/src/main/java/module-info.java b/src/Welsh Vocabulary Tutor/src/main/java/module-info.java index 1013357..3918209 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/module-info.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/module-info.java @@ -3,8 +3,8 @@ module uk.ac.aber.cs22120.group20 { requires javafx.fxml; requires com.fasterxml.jackson.core; requires com.fasterxml.jackson.databind; - requires junit; requires org.junit.jupiter.api; + requires org.testfx; opens uk.ac.aber.cs22120.group20.javafx to javafx.fxml; @@ -16,5 +16,6 @@ module uk.ac.aber.cs22120.group20 { exports uk.ac.aber.cs22120.group20.json to com.fasterxml.jackson.databind; exports uk.ac.aber.cs22120.group20.javafx to javafx.graphics, javafx.fxml; + exports uk.ac.aber.cs22120.group20.test to org.junit.jupiter.api,org.junit.platform.commons; // exports uk.ac.aber.cs22120.group20.test to junit; } \ No newline at end of file diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/JSONTest.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/JSONTest.java index 3cefe57..f5ac4b0 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/JSONTest.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/JSONTest.java @@ -1,9 +1,6 @@ package uk.ac.aber.cs22120.group20.test; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.Assert; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import uk.ac.aber.cs22120.group20.json.DictionaryEntry; @@ -14,6 +11,8 @@ import java.io.FileWriter; import java.util.Arrays; import java.util.LinkedList; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + /** * Class that contains methods which will be used to test that the JSON package classes are * correctly loading and saving to and from the JSON file. @@ -28,7 +27,7 @@ public class JSONTest { JsonProcessing processor = new JsonProcessing(); - @Before + @BeforeAll public void setupTest() { // Populate a test list with DictionaryEntrys that is to be used for the loading/saving tests. @@ -51,7 +50,7 @@ public class JSONTest { // Load the DictionaryEntry's from testFile and check if the loaded list matches the test list. loadedList = processor.readInJson(testFile); - Assert.assertArrayEquals(testList.toArray(),loadedList.toArray()); + assertArrayEquals(testList.toArray(),loadedList.toArray()); } /** @@ -65,10 +64,10 @@ public class JSONTest { // Load the DictionaryEntry's back from the file and check that they match the testList. loadedList = processor.readInJson(testFile); - Assert.assertArrayEquals(testList.toArray(), loadedList.toArray()); + assertArrayEquals(testList.toArray(), loadedList.toArray()); } - @After + @AfterAll public void deleteFile() { testFile.delete(); } diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java index e40bc2d..62274ee 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java @@ -1,6 +1,5 @@ package uk.ac.aber.cs22120.group20.test; -import org.junit.Before; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import uk.ac.aber.cs22120.group20.javafx.TranslationController;