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.
This commit is contained in:
law39 2020-04-30 11:26:43 +01:00
parent d5ef05b76e
commit 740f7b5206
4 changed files with 35 additions and 19 deletions

View file

@ -20,20 +20,37 @@
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.4.2</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter</artifactId>-->
<!-- <version>5.4.2</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.4</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>junit</groupId>-->
<!-- <artifactId>junit</artifactId>-->
<!-- <version>RELEASE</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit5</artifactId>
<version>4.0.16-alpha</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
@ -52,7 +69,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>uk.ac.aber.cs22120.group20.Application</mainClass>
<mainClass>uk.ac.aber.cs22120.group20.javafx.Application</mainClass>
</configuration>
</plugin>
</plugins>

View file

@ -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;
}

View file

@ -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();
}

View file

@ -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;