10
FEST(A)! - TESTING SWING COMPONENTS WITH FEST Andreas Enbohm, Capgemini

Fest

Embed Size (px)

DESCRIPTION

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

Citation preview

Page 1: Fest

FEST(A)!- TESTING SWING COMPONENTS WITH FEST

Andreas Enbohm, Capgemini

Page 2: Fest

April 8, 2023

Sida 2

Agenda

Basics of FEST

Code Examples and Demo

B & C’s

How ERE uses Fest

Q&A

Page 3: Fest

April 8, 2023

Sida 3

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:

1. Simulation of user interaction with a GUI (e.g. mouse and keyboard input)

2. Reliable GUI component lookup (by type, by name or custom search criteria)

3. Support for all Swing components included in the JDK

4. Supports Applet testing

5. Ability to embed screenshots of failed GUI tests in HTML test reports

6. Verifying colors and fonts

Page 4: Fest

April 8, 2023

Sida 4

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

Page 5: Fest

April 8, 2023

Sida 5

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)

Page 6: Fest

April 8, 2023

Sida 6

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");

Page 7: Fest

April 8, 2023

Sida 7

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);

Page 8: Fest

April 8, 2023

Sida 8

DEMO

Verify Title

Verify Button Click Behaviour

Screenshots when test fails

Page 9: Fest

April 8, 2023

Sida 9

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

Page 10: Fest

April 8, 2023

Sida 10

FEST

Q&A

http://fest.easytesting.org/swing/wiki/pmwiki.php