package deltadak;

import javafx.scene.control.ProgressIndicator;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
 * Tests {@link HelloJavaFX} class.
 */
class HelloJavaFXTest {

    /**
     * Test {@link HelloJavaFX#calculate()} method.
     */
    @Test
    public void testCalculate(){
        HelloJavaFX helloJavaFX = new HelloJavaFX();

        assertEquals(2, helloJavaFX.calculate(), "message");
    }

    @Test
    public void testProgress() {
        HelloJavaFX helloJavaFX = new HelloJavaFX();
        ProgressIndicator progressIndicator = new ProgressIndicator();

        assertTrue(helloJavaFX.setLoading(progressIndicator));
    }

}
package deltadak;

import javafx.scene.control.ProgressIndicator;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
 * Tests {@link HelloJavaFX} class.
 */
class HelloJavaFXTest {

    /**
     * Test {@link HelloJavaFX#calculate()} method.
     */
    @Test
    public void testCalculate(){
        HelloJavaFX helloJavaFX = new HelloJavaFX();

        assertEquals(2, helloJavaFX.calculate(), "message");
    }

    /**
     * Fails on `new ProgressIndicator();` line.
     */
    @Test
    public void testProgress() {
        HelloJavaFX helloJavaFX = new HelloJavaFX();

        // Initialise JavaFX Toolkit, needed for using elements like ProgressIndicator.
        com.sun.javafx.application.PlatformImpl.startup(()->{});

        ProgressIndicator progressIndicator = new ProgressIndicator();

        assertTrue(helloJavaFX.setLoading(progressIndicator));

        // Shutdown toolkit.
        com.sun.javafx.application.PlatformImpl.exit();
    }

}
fix tests by initialising fx toolkit