functional testing swing user interfaces with …functional testing swing user interfaces with...

86
© ThoughtWorks, 2006 Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks

Upload: others

Post on 13-Jul-2020

35 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Functional Testing Swing

User Interfaces with

Frankenstein

Vivek Prahlad

Senior Developer, ThoughtWorks

Page 2: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Agenda

• Why a new tool?

• Introduction to Frankenstein

• Demo

• Q & A

Page 3: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Why?

Page 4: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Swing Client, pre-existing

FIT scripts

Page 5: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Needed to write fixtures for new screens

Page 6: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Did not test actual UI

Page 7: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Tested UI model layer

Page 8: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

UI Model

FIT Fixtures Screens

Page 9: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

No Swing driver

Page 10: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Duplication

Page 11: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Enter UserName foo

Enter Password bar

Initiate Login

Navigate Create>Blog Entry

...

Page 12: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Enter UserName foo

Enter Password bar

Initiate Login

Navigate Edit>Blog Entry

...

Page 13: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Not easy to create fixtures

Page 14: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Writing fixtures slowed down

development

Page 15: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Additional features

Page 16: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Record & Play

Page 17: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Multithreaded apps?

Page 18: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Swing is single threaded

Page 19: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

but

Page 20: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Serious Swing apps use

worker threads

Page 21: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Page 22: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Page 23: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

What's the problem?

Page 24: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Tests with arbitrary waits

Page 25: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

click_button(“connect”)

wait(20) //Pray!

do_something_else

Page 26: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Fragile,slow tests

Page 27: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Explicit Synchronization

Page 28: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

wait_for_text(“done”)

Page 29: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Verbose tests

Page 30: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

upload_file(“file”)

wait_for_text(“done”)

Page 31: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Obscures intent

Page 32: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Custom components?

Page 33: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Evaluated Abbot, Marathon

Page 34: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Didn't quite have what we'd

wanted

Page 35: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

'Let's write it!'

-Chris Stevenson

Page 36: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Introducing Frankenstein

Page 37: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Page 38: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

FIT like scripts

Page 39: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Navigate Create>Blog

EnterText post *my blog text*

SelectDropDown time now

ClickButton Post

Page 40: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Plain text

Page 41: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Easy to write, Human Readable

Page 42: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Human Readable

Page 43: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Human Readable

Page 44: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Understood (and shared) by the whole team

Page 45: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Record & Playback

Page 46: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

..useful for reproducing bugs

Page 47: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

No arbitrary waits

Page 48: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Works with JDK 1.4+

Page 49: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Code changes?

Page 50: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Name components with component.setName()

Page 51: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Works with applications where codebase cannot be

modified

Page 52: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

...with a few limitations

Page 53: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Not easy record custom components

Page 54: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

i18n

Page 55: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Test multithreaded apps viaWorkerThreadMonitor

Page 56: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

public interface WorkerThreadMonitor {

public void start();

public void waitForIdle();//blocking

}

Page 57: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Page 58: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

How is the WorkerThreadMonitor used?

Page 59: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Wait for all Swing events to be completed

Page 60: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Wait for all worker threads to complete

Page 61: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Easy to extend test vocabulary

Page 62: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Add assertions

Page 63: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Easy integration

Page 64: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

java com.yourapp.MainClass args...

Page 65: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

java com.thoughtworks.frankenstein.application.PipingMain com.yourapp.MainClass args...

Page 66: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

..or write your own main class

Page 67: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Custom recorders for custom components

Page 68: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Ruby driver

Page 69: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Variables, functions

Page 70: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Keep tests DRY

Page 71: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Other language drivers easy to add

Page 72: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

~ 1500 LOC

Page 73: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

98% test coverage

Page 74: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Demo

Page 75: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

How does it work?

Page 76: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Recorders hook onto Swing Event Queue

Page 77: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Add component-specific listeners

Page 78: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Create Events when listeners are triggered

Page 79: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Events know how to replay themselves

Page 80: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

IOC + PicoContainer

Page 81: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

What's missing?

Page 82: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

More assertions

Page 83: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Support for relatively less used components

Page 84: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Open Sourcing soon

Page 85: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Thank You

Page 86: Functional Testing Swing User Interfaces with …Functional Testing Swing User Interfaces with Frankenstein Vivek Prahlad Senior Developer, ThoughtWorks ©ThoughtWorks, 2006 Agenda

© ThoughtWorks, 2006

Blog at http://www.vivekprahlad.com

Email:

[email protected]