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