Add JUnit extension for tests
This commit is contained in:
parent
e415674cf7
commit
fbbcaa37f9
18
base/src/test/java/atlantafx/base/JavaFXTest.java
Normal file
18
base/src/test/java/atlantafx/base/JavaFXTest.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package atlantafx.base;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||||
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
|
||||||
|
public class JavaFXTest implements BeforeAllCallback {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeAll(ExtensionContext context) {
|
||||||
|
try {
|
||||||
|
Platform.startup(() -> {
|
||||||
|
});
|
||||||
|
} catch (Throwable t) {
|
||||||
|
// https://bugs.openjdk.org/browse/JDK-8090933 (2013!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,22 +2,17 @@ package atlantafx.base.layout;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import atlantafx.base.JavaFXTest;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
@ExtendWith({JavaFXTest.class})
|
||||||
public class DeckPaneTest {
|
public class DeckPaneTest {
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void startup() {
|
|
||||||
Platform.startup(() -> {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTopNodeOnNewlyCreatedDeck() {
|
public void testTopNodeOnNewlyCreatedDeck() {
|
||||||
var emptyDeck = new DeckPane();
|
var emptyDeck = new DeckPane();
|
||||||
|
@ -3,19 +3,14 @@ package atlantafx.base.util;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import atlantafx.base.JavaFXTest;
|
||||||
import javafx.scene.control.TextField;
|
import javafx.scene.control.TextField;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
@ExtendWith({JavaFXTest.class})
|
||||||
public class PasswordTextFormatterTest {
|
public class PasswordTextFormatterTest {
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void startup() {
|
|
||||||
Platform.startup(() -> {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTextIsMaskedByDefault() {
|
public void testTextIsMaskedByDefault() {
|
||||||
var field = new TextField();
|
var field = new TextField();
|
||||||
|
Loading…
Reference in New Issue
Block a user