Easy GUI Testing with FEST
   Alex Ruiz          Yvonne W. Price
  Software Engineer    Software Engineer

          Oracl...
Overall Presentation Goal




 Learn a simple and easy way to test
        Swing GUI applications




                    ...
Speaker’s Qualifications

   Alex Ruiz writes articles about testing and DSLs
    for several publications
   Alex speak...
Do you test your GUIs?




    Testing GUIs, although essential, has
            been difficult to achieve




           ...
Do you test your GUIs?




    Testing GUIs, although essential, has
            been difficult to achieve

              ...
Agenda


   Introducing FEST
   Features
   Roadmap
   Demo
   Summary
   Q&A




                       www.javapol...
Introducing FEST


   Library for functional GUI testing
   Open Source (Apache 2.0 license)
   Supports both JUnit and...
Features


   Robust GUI testing
   Easy test setup
   DSL-oriented, “fluent” API
   Screenshots of failing tests
   ...
Features
 Robust GUI Testing
 Simulates user events



   Provides a reliable mechanism for finding GUI
    components
 ...
Features
    Easy Test Setup
   Example:
private FrameFixture frame;

@BeforeMethod public void setUp() {
  frame = new F...
Features
 DSL-Oriented, “Fluent” API
Example:
 Test that the text of label changes to “bye!”

  when clicking the “Bye” b...
Features
    DSL-Oriented, “Fluent” API
   Right-click a specific item in a JList:
    list("employees").item("Gandalf")
...
Features
    DSL-Oriented, “Fluent” API
   Click a list 2 times:
    list("employees").doubleClick();
    list("employees...
Features
    Screenshots of Failing Tests
   Takes a picture of the desktop if a GUI test
    fails

   Supports both JU...
Features
    Screenshots of Failing Tests
   JUnit:
        @RunWith(GUITestRunner.class)
        Ant’s “junit” task


...
Features
    Screenshots of Failing Tests
   TestNG:
        ScreenshotOnFailureListener




                        www...
Features
    Drag ‘n Drop
   Example: drag from list and drop in table


frame.list("projects").drag("FEST");
frame.table...
Features
    Testing Long-Duration Tasks
   Example: Successful login

// simulate a user login in
login.textBox("usernam...
Features
    Testing Legacy Applications
   Legacy applications may not have unique
    GUI component names

   Example:...
Roadmap


   Finish Groovy support
   Add support for testing GUIs in other JVMs
   Finish pending features
   January...
Roadmap
 Groovy Support (quick peek)
fixture.frame(new MyFrame()) {
      show(width: 400, height: 200)

       textBox("n...
Demo
Testing a Login Window
Demo

   Testing a Login Window




                             www.javapolis.com
Demo

   Testing a Login Window




                             www.javapolis.com
Links


   FEST website: http://fest.easytesting.org/
    swing/
        Getting started guide, Javadocs, feature
      ...
Summary


   FEST is an open source library that makes
    functional GUI testing really simple and
    easy
   Its DSL-...
Concluding Statement




 FEST makes GUI testing easy and simple.

  There are no more excuses for not testing
           ...
Q&A
View JavaPolis talks @ www.parleys.com
Thank you for your
    attention
Upcoming SlideShare
Loading in …5
×

Easy GUI Testing with FEST

5,716 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,716
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
79
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Easy GUI Testing with FEST

  1. 1. Easy GUI Testing with FEST Alex Ruiz Yvonne W. Price Software Engineer Software Engineer Oracle Corporation
  2. 2. Overall Presentation Goal Learn a simple and easy way to test Swing GUI applications www.javapolis.com
  3. 3. Speaker’s Qualifications  Alex Ruiz writes articles about testing and DSLs for several publications  Alex speaks frequently about testing at conferences  Alex works on the core IDE platform at Oracle using Swing  Yvonne Wang Price has written about Test-Driven GUI Development for IEEE Software  Yvonne speaks frequently about GUI testing at conferences www.javapolis.com
  4. 4. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve www.javapolis.com
  5. 5. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve …until now! www.javapolis.com
  6. 6. Agenda  Introducing FEST  Features  Roadmap  Demo  Summary  Q&A www.javapolis.com
  7. 7. Introducing FEST  Library for functional GUI testing  Open Source (Apache 2.0 license)  Supports both JUnit and TestNG  DSL-oriented API that is both easy to read and write  Supports all Swing components included in the JDK www.javapolis.com
  8. 8. Features  Robust GUI testing  Easy test setup  DSL-oriented, “fluent” API  Screenshots of failing tests  Drag ‘n Drop  Testing long-duration tasks  Testing legacy/existing applications www.javapolis.com
  9. 9. Features Robust GUI Testing  Simulates user events  Provides a reliable mechanism for finding GUI components  By name  By type  By Custom Search Criteria  Tolerates changes in a component's position and/ or layout. www.javapolis.com
  10. 10. Features Easy Test Setup  Example: private FrameFixture frame; @BeforeMethod public void setUp() { frame = new FrameFixture(new MyFrame()); frame.show(); } @AfterMethod public void tearDown() { frame.cleanUp(); } www.javapolis.com
  11. 11. Features DSL-Oriented, “Fluent” API Example:  Test that the text of label changes to “bye!” when clicking the “Bye” button: @Test public void shouldChangeTextWhenClickingButton() { frame.button("byeButton").click(); frame.label("messageLabel").requireText("Bye!"); } www.javapolis.com
  12. 12. Features DSL-Oriented, “Fluent” API  Right-click a specific item in a JList: list("employees").item("Gandalf") .rightClick();  Show a JPopupMenu in a JTextField and select “Copy”: textBox("name").showPopupMenu() .selectItem("Copy");  Double-click a specific cell in a JTable: table("name").cell(row(0).column(3)) .doubleClick(); www.javapolis.com
  13. 13. Features DSL-Oriented, “Fluent” API  Click a list 2 times: list("employees").doubleClick(); list("employees").click(leftButton().times(2)); www.javapolis.com
  14. 14. Features Screenshots of Failing Tests  Takes a picture of the desktop if a GUI test fails  Supports both JUnit and TestNG  Plugs into existing reporting infrastructure with minimal changes www.javapolis.com
  15. 15. Features Screenshots of Failing Tests  JUnit:  @RunWith(GUITestRunner.class)  Ant’s “junit” task www.javapolis.com
  16. 16. Features Screenshots of Failing Tests  TestNG:  ScreenshotOnFailureListener www.javapolis.com
  17. 17. Features Drag ‘n Drop  Example: drag from list and drop in table frame.list("projects").drag("FEST"); frame.table("active").drop(row(2).column(0)); www.javapolis.com
  18. 18. Features Testing Long-Duration Tasks  Example: Successful login // simulate a user login in login.textBox("username").enterText("frodo"); login.textBox("password").enterText("ring"); login.button("ok").click(); // wait for authentication/authorization to // finish, and get a reference to the main // window FrameFixture mainFrame = findFrame("main").withTimeout(10, SECONDS) .using(robot); www.javapolis.com
  19. 19. Features Testing Legacy Applications  Legacy applications may not have unique GUI component names  Example: find button with text “OK” GenericTypeMatcher<JButton> textMatcher = new GenericTypeMatcher<JButton>() { protected boolean isMatching(JButton button) { return "OK".equals(button.getText()); } }; dialog.button(textMatcher).click(); www.javapolis.com
  20. 20. Roadmap  Finish Groovy support  Add support for testing GUIs in other JVMs  Finish pending features  January/February 2008: FEST 1.0!  Add support for SwingX, JIDE and Flamingo Component Suite  Add JRuby-based API  A really nice surprise coming up!!  www.javapolis.com
  21. 21. Roadmap Groovy Support (quick peek) fixture.frame(new MyFrame()) { show(width: 400, height: 200) textBox("name") { enterText("Leia") select("ia") } button("ok") { click() } } www.javapolis.com
  22. 22. Demo Testing a Login Window
  23. 23. Demo  Testing a Login Window www.javapolis.com
  24. 24. Demo  Testing a Login Window www.javapolis.com
  25. 25. Links  FEST website: http://fest.easytesting.org/ swing/  Getting started guide, Javadocs, feature references, examples, articles, etc.  Books:  “Java Power Tools” by John Ferguson Smart (February 2008)  “Next Generation Java Testing” by Cédric Beust and Hani Suleiman www.javapolis.com
  26. 26. Summary  FEST is an open source library that makes functional GUI testing really simple and easy  Its DSL-oriented API is easy to write and read, reducing time spent writing and maintaining tests  FEST provides useful debugging features that can help us diagnose testing failures www.javapolis.com
  27. 27. Concluding Statement FEST makes GUI testing easy and simple. There are no more excuses for not testing our GUIs! What are you waiting for? Start testing!! www.javapolis.com
  28. 28. Q&A View JavaPolis talks @ www.parleys.com
  29. 29. Thank you for your attention

×