views:

145

answers:

3

Testing UI is difficult. What do you think is the best unit testing framework for Swing?

+3  A: 

I have been using Jemmy on top of JUnit. You can see a snippet of their example test-case actions here:

    new ClassReference("org.netbeans.jemmy.explorer.GUIBrowser")
        .startApplication();
    JFrameOperator mainFrame = new JFrameOperator("GUI Browser");

    new JButtonOperator(mainFrame, "Reload In").push();
    new JLabelOperator(mainFrame, "Reloaded");

    JTreeOperator tree = new JTreeOperator(mainFrame);

    //click in the middle of the tree
    tree.clickMouse();

    //collapse node     
    tree.collapsePath(tree.findPath("", "|"));

    //expand node       
    tree.expandPath(tree.findPath("", "|"));

    //select node
    tree.selectPath(tree.findPath("GUI Browser", "|"));

    JTextFieldOperator testField = new JTextFieldOperator(mainFrame);

    //type new value in the text field
    testField.clearText();
    testField.typeText("3");
tucuxi
+1  A: 
Alfred
+3  A: 

Currently the best in my opinion is FEST.

eugener