Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.



Published on

A nice way of testing swing component using fest (fixture for easy testing).

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this


  1. 1. FEST(A)! - TESTING SWING COMPONENTS WITH FEST Andreas Enbohm, Capgemini
  2. 2. Agenda <ul><li>Basics of FEST </li></ul><ul><li>Code Examples and Demo </li></ul><ul><li>B & C’s </li></ul><ul><li>How ERE uses Fest </li></ul><ul><li>Q&A </li></ul>
  3. 3. FEST <ul><li>Fixtures For Easy Software Testing, released nov - 08 </li></ul><ul><li>Java-based framework, works with JUnit, TestNG, standalone </li></ul><ul><li>Several modules in FEST (swing, assert, reflect, mocking) </li></ul><ul><li>’ Fluent Interface’ (a.k.a. internal DSL) </li></ul><ul><li>Features: </li></ul><ul><ul><li>Simulation of user interaction with a GUI (e.g. mouse and keyboard input) </li></ul></ul><ul><ul><li>Reliable GUI component lookup (by type, by name or custom search criteria) </li></ul></ul><ul><ul><li>Support for all Swing components included in the JDK </li></ul></ul><ul><ul><li>Supports Applet testing </li></ul></ul><ul><ul><li>Ability to embed screenshots of failed GUI tests in HTML test reports </li></ul></ul><ul><ul><li>Verifying colors and fonts </li></ul></ul>
  4. 4. FEST – Swing Module <ul><li>Supported Input - Mouse - Keyboard - Drag ’n Drop </li></ul><ul><li>Support of Running Tests without any desktop installed - Xvfb - Good for both CI and local environment </li></ul><ul><li>Apache 2.0 License, Hosted at Google Code </li></ul>
  5. 5. FEST – Swing Module <ul><li>Fixtures - one fixture per swing component (e.g. JButtonFixture ) - provide method for user interaction, - implicit assertions, if ’click’ fails an assertion error is thrown - good for testing ’single’ UI component (see demo) </li></ul><ul><li>Robot - used for looking up various components - used for more low level operations - requires more work than using fixtures - needs to be used if testing ’running application’ (see demo) </li></ul>
  6. 6. FEST – Swing Module <ul><li>Simple Example </li></ul>FrameFixture dialog = new FrameFixture(new MyFrame()); dialog.comboBox(&quot;domain&quot;).select(&quot;Users&quot;); dialog.textBox(&quot;username&quot;).enterText(“Chuck Norris&quot;); dialog.button(&quot;login&quot;).click(); //Assert we have an error message dialog.optionPane().requireErrorMessage().requireMessage(&quot;Please enter your password&quot;);
  7. 7. FEST - Extensions <ul><li>FEST – Assert with fluent interfaces </li></ul><ul><li>FEST – Reflect </li></ul><ul><li>FEST – Mocking </li></ul>int removed = employees.removeFired(); assertThat(removed).isZero(); List<Employee> newEmployees = employees.hired(TODAY); ‘ assertThat(newEmployees).hasSize(6).contains(frodo, sam); String[] newHires = employees.newHiresNames(); assertThat(newHires).containsOnly(&quot;Gandalf&quot;, &quot;Arwen&quot;, &quot;Gimli&quot;); assertThat(yoda).isInstanceOf(Jedi.class).isEqualTo(foundJedi).isNotEqualTo(foundSith);
  8. 8. DEMO <ul><li>Verify Title </li></ul><ul><li>Verify Button Click Behaviour </li></ul><ul><li>Screenshots when test fails </li></ul>
  9. 9. FEST – B & C’s <ul><li>Easy to begins with, very much like writing ’usual’ tests </li></ul><ul><li>Taking screenshots when test failures </li></ul><ul><li>Good documentation </li></ul><ul><li>Access / update GUI components – should be done via EDT </li></ul><ul><li>Different behaviour (i.e. focus problem, Z-order of windows) of different platforms. May result in test failure </li></ul><ul><li>Not possible to record user interaction </li></ul><ul><li>Test takes long time to run </li></ul>
  10. 10. FEST <ul><li>Q&A </li></ul><ul><li> </li></ul>