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

4,174
views

Published on


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

No Downloads
Views
Total Views
4,174
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
60
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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 www.javapolis.com
  • 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. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve www.javapolis.com
  • 5. Do you test your GUIs? Testing GUIs, although essential, has been difficult to achieve …until now! www.javapolis.com
  • 6. Agenda  Introducing FEST  Features  Roadmap  Demo  Summary  Q&A www.javapolis.com
  • 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. 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. 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. 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. 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. 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. Features DSL-Oriented, “Fluent” API  Click a list 2 times: list("employees").doubleClick(); list("employees").click(leftButton().times(2)); www.javapolis.com
  • 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. Features Screenshots of Failing Tests  JUnit:  @RunWith(GUITestRunner.class)  Ant’s “junit” task www.javapolis.com
  • 16. Features Screenshots of Failing Tests  TestNG:  ScreenshotOnFailureListener www.javapolis.com
  • 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. 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. 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. 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. 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. Demo Testing a Login Window
  • 23. Demo  Testing a Login Window www.javapolis.com
  • 24. Demo  Testing a Login Window www.javapolis.com
  • 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. 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. 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. Q&A View JavaPolis talks @ www.parleys.com
  • 29. Thank you for your attention