Running Test FX Tests (JDK 7 Doesn't Work... JDK 8 Does)

458 views
Skip to first unread message

Lane Feltis

unread,
Feb 3, 2014, 3:33:44 PM2/3/14
to testfx-...@googlegroups.com
Note: Henrik, thanks for releasing 3.1.2 and fixing the window size issue, it is working perfectly now!

I have been using JDK 8 because it is the only version that I can successfully run Test FX tests with. If I run it using JDK 7 (latest release 51, early adopter 60, previous version 45, 25 or 6) I get the following error...

java.lang.RuntimeException: Unable to show stage
at org.loadui.testfx.GuiTest.showNodeInStage(GuiTest.java:119)
at org.loadui.testfx.GuiTest.showNodeInStage(GuiTest.java:103)
at org.loadui.testfx.GuiTest.setupStage(GuiTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.util.concurrent.TimeoutException: Timeout waiting for task.
at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:276)
at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:96)
at org.loadui.testfx.GuiTest.showNodeInStage(GuiTest.java:114)
... 28 more

...however, if I have any version of JDK 8 installed, it works fine. My issue is that I am trying to get code coverage into our build and ideally I would like to use the out of the box jacoco plugin for gradle. For some reason, jacoco (and other code coverage plugins I tried) don't play so nice with Test FX and Java 8. Since Test FX was designed for Java 7, I was hoping to rollback to a Java 7 version to more easily get code coverage integrated. Is anyone else having trouble even running simply tests in Java 7? I am trying to run this simple test below and I am getting the error above...

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.control.Button;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.loadui.testfx.GuiTest;
import org.loadui.testfx.categories.TestFX;

import static org.loadui.testfx.Assertions.verifyThat;
import static org.loadui.testfx.controls.Commons.hasText;

@Category(TestFX.class)
public class SimpleButtonTest extends GuiTest {
    @Override
    protected Parent getRootNode() {
        final Button btn = new Button();
        btn.setId("btn");
        btn.setText("Hello World");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent actionEvent) {
                btn.setText( "was clicked" );
            }
        });

        return btn;
    }

    @Test
    public void shouldClickButton(){
        final Button button = find( "#btn" );
        click(button);
        verifyThat( "#btn", hasText("was clicked") );
    }
}

...any thoughts? Can you run this simple test in Java 7? Thanks!

Henrik

unread,
Feb 4, 2014, 6:13:28 AM2/4/14
to Lane Feltis, testfx-...@googlegroups.com
Does it work without jacoco?

I run the test that you posted from IntelliJ on Windows and it was successful:

"C:\Program Files\Java\jdk1.7.0_45\bin\java" -ea -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.0.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.0.1\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.0.1\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_45\jre\lib\ext\zipfs.jar;C:\Users\Henrik\Documents\GitHub\TestFX\target\test-classes;C:\Users\Henrik\Documents\GitHub\TestFX\target\classes;C:\Users\Henrik\.m2\repository\com\google\guava\guava\14.0.1\guava-14.0.1.jar;C:\Users\Henrik\.m2\repository\org\hamcrest\hamcrest-all\1.3\hamcrest-all-1.3.jar;C:\Users\Henrik\.m2\repository\junit\junit\4.10\junit-4.10.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 org.loadui.testfx.SimpleButtonTest

Process finished with exit code 0



--
You received this message because you are subscribed to the Google Groups "TestFX" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testfx-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Message has been deleted

Lane Feltis

unread,
Feb 4, 2014, 2:12:54 PM2/4/14
to testfx-...@googlegroups.com, Lane Feltis
I was running it without Jacoco or anything else, just to try to get this simple Test FX file working. I am developing on a MAC... I'll see if I can get it working on Windows and provide some more feedback, thanks.

Lane Feltis

unread,
Feb 4, 2014, 3:45:56 PM2/4/14
to testfx-...@googlegroups.com, Lane Feltis
I verified that this works on Windows 7, but I am still unsure why it is failing on a MAC. If anyone has this working on a MAC, please provide details of your environment and setup. Thanks!
Reply all
Reply to author
Forward
0 new messages