FEST-Swing
Swing



          @hakurai
Java, C, C++, Scala, Groovy
Swing
FEST-Swing




• Swing

• JUnit
Swing




• Java GUI


•       AWT SWT
FEST-Swing

  1.robot
  2.
  3.
 4.
  5.assert
1.robot




robot = BasicRobot.robotWithNewAwtHierarchy();
2.

//main
ApplicationLauncher.application( SampleFrame.class ).start();




//
JFrame myJFrame = new MyJFrame();
myJFrame.setVisible( true );




                                                 MyJFrame
3.

//JFrame
FrameFixture frame = WindowFinder.findFrame( MyJFrame.class ).using( robot );

//
FrameFixture frame = new FrameFixture( robot, myJFrame );




                                                      JFrameFixture
4.
//
JTextComponentFixture accountField = frame.textBox( “accountField” );
accountField.enterText( “root” );


//OK
JButtonFixture okButton = frame.button( “okButton” );
okButton.click();


                          “root”                        “accountField”


                                                              “okButton”


                          click
                                                  JFrameFixture
Fixture
• Swing

• Fixture

•

•
Fixture


•                     Fixture

• Finder         (              )

• Fixture
Swing


                            JFrame


             JPanel                  JPanel



JTextField        JButton            JButton
Fixture




•                name



• GenericTypeMatcher
name


//name   accountField textBox
frame.textBox( “accountField” ).



                               “accountField”




                           JFrameFixture
name


• ComponentLookupException

•          name

•

•          GenericTypeMatcher

•          Fixture
JFrame


             JPanel                   JPanel



JTextField        JButton             JButton
                okButton             okButton
• Fixture
                    click()
                doubleClick()
            enterText( String text )
                    drag()
                                  etc
• Fixture

• require

• JUnit assert
                 requireText( String text )
                 requireEditable()
                 requireEnabled()
                 requireVisible()
                 etc
• FEST-Swing EDT

•
• Timeout

• Pause        Condition
requireEnabled(Timeout timeout)

Pause
pause( Condition condition, Timeout timeout)
Pause

•      Condition


• Timeout

•                          WaitTimedOutError

Automate the Swing application testing