Return_Of_The_Archons
Return_Of_The_Archons

Reputation: 1789

How can I run testfx tests in series?

I've got 2 testfx tests which each run successfully but when run in series, fail. The error message is:

--- Exception in Async Thread ---
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Cannot set style once stage has been set visible
java.util.concurrent.FutureTask.report(FutureTask.java:122)
...

I initialised the test by creating the stage:

@Before
public void setUp() throws Exception {

    FxToolkit.registerPrimaryStage();
    setupStage((stage -> {

        Undecorator undecorator;
        ....

It seems that the thread isn't letting go of the stage the first time round. I've tried several things from the testfx forum to kill it before the second test starts including FxToolkit.hideStage(); and Platform.exit();.

I'm using org.testfx:testfx-junit:4.0.6-alpha. Any thoughts?

Thanks, Andy

Upvotes: 2

Views: 1035

Answers (1)

D-Dᴙum
D-Dᴙum

Reputation: 7890

Your error message is telling you the problem:

Cannot set style once stage has been made visible

As stated in the Stage.initStyle() method you need to set the style before the stage has been set visible. You can confirm this by looking tinto the source code for Application class.

The only way to get around this issue is to re-start the JVM for each test if you need to set properties that are 'one-time-set'.

Upvotes: 1

Related Questions