Can't create FrameFixture with Fest + Swing

901 Views Asked by At

I am trying to make a simple test after the Fest Tutorial for a JFrame, JButton.

Here's my code:

    private FrameFixture window;

    @Before
    public void setUp() {
    MyMainFrame myMainFrame = GuiActionRunner.execute(new GuiQuery<MyMainFrame>(){
        protected MyMainFrame executeInEDT()
            {
                return new MyMainFrame();
            }
        });
    window = new FrameFixture(myMainFrame);
    window.show();     
}

No matter what i do, the code crushes (casues error) at the creation of the FrameFixture; I even tried to replace myMainFrame with new JFrame.

errors i get:

org/fest/reflect/exception/ReflectionError
java.lang.NoClassDefFoundError
at org.fest.swing.input.InputState.<init>(InputState.java:42)
at org.fest.swing.fixture.WindowFixture.<init>(WindowFixture.java:103)
at org.fest.swing.fixture.FrameFixture.<init>(FrameFixture.java:49)
at javatestgui.MainFrameTest.setUp(MainFrameTest.java:48)
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

and

Could not initialize class org.fest.swing.core.BasicRobot
java.lang.NoClassDefFoundError
at org.fest.swing.fixture.WindowFixture.<init>(WindowFixture.java:103)
at org.fest.swing.fixture.FrameFixture.<init>(FrameFixture.java:49)
at javatestgui.MainFrameTest.setUp(MainFrameTest.java:48)

Any help what's going wring?

2

There are 2 best solutions below

0
On

You Need to add all the Jars inside the folder fest-swing ,

fest-swing-1.2.jar lib/fest-assert-1.2.jar lib/fest-reflect-1.2.jar lib/fest-util-1.1.2.jar lib/jcip-annotations-1.0.jar

0
On

Well, I was getting a similar error and all I had to do was include all the jars (barring the *-sources.jar ones) in the /lib folder found inside the fest-swing-1.2.zip file plus adding hamcrest-core-1.3.jar