Your SlideShare is downloading. ×
Easy GUI Testing with FEST
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Easy GUI Testing with FEST


Published on

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Easy GUI Testing with FEST Alex Ruiz Yvonne W. Price Software Engineer Software Engineer Oracle Corporation
  • 2. Overall Presentation Goal Learn a simple and easy way to test Swing GUI applications
  • 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
  • 4. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve
  • 5. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve …until now!
  • 6. Agenda  Introducing FEST  Features  Roadmap  Demo  Summary  Q&A
  • 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
  • 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
  • 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.
  • 10. Features Easy Test Setup  Example: private FrameFixture frame; @BeforeMethod public void setUp() { frame = new FrameFixture(new MyFrame());; } @AfterMethod public void tearDown() { frame.cleanUp(); }
  • 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!"); }
  • 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();
  • 13. Features DSL-Oriented, “Fluent” API  Click a list 2 times: list("employees").doubleClick(); list("employees").click(leftButton().times(2));
  • 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
  • 15. Features Screenshots of Failing Tests  JUnit:  @RunWith(GUITestRunner.class)  Ant’s “junit” task
  • 16. Features Screenshots of Failing Tests  TestNG:  ScreenshotOnFailureListener
  • 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));
  • 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);
  • 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();
  • 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!! 
  • 21. Roadmap Groovy Support (quick peek) fixture.frame(new MyFrame()) { show(width: 400, height: 200) textBox("name") { enterText("Leia") select("ia") } button("ok") { click() } }
  • 22. Demo Testing a Login Window
  • 23. Demo  Testing a Login Window
  • 24. Demo  Testing a Login Window
  • 25. Links  FEST website: 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
  • 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
  • 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!!
  • 28. Q&A View JavaPolis talks @
  • 29. Thank you for your attention