Specification by Example with GUI tests - 
How could that work? 
Emily Bache, Bache Consulting & Pagero 
Geoff Bache, Jeppesen 
@esconfs 
#esconfs
Specification by Example 
with Rich-Client application? 
3
Jeppesen 
 Agile transition underway 
 next-generation Crew Management System 
4
5
Specification by Example 
6
Specification by Example 
 Gojko Adzic’s book 
 Collaborative workshops 
 Define Example Scenarios BEFORE 
build code 
7
Agile Requirements 
User Story + Conversation + Examples 
= Requirement 
From “Agile Testing” by Crispin, Gregory 
8 
aka Scenarios
Scenario -> Regression test 
 BEFORE code is written, it’s a requirement 
specification 
 AFTER code is written it’s a regression test 
Important to preserve the language & format 
9 
Living Documentation
GUI testing 
with Record - Replay 
10
Recorded GUI Tests 
 Click around the GUI like a user 
would 
 Record a script 
 Re-play the script to regression 
test 
11 
Assumes the GUI is already built
Recorded Scripts 
Easy to create, hard to maintain 
12
Page Object Pattern 
13 
Test Case Scripts 
Hand Coded 
Page Objects 
Hand Coded 
System Under Test
GUI testing 
with Cucumber, Fitnesse etc 
14
Using Cucumber 
Feature 
http://cukes.info 
Step Definitions 
System Under Test (SUT)
Using Fitnesse 
16 
http://fitnesse.org
“Domain Language” Tests 
Domain Language 
Scenario or Table 
Test Fixture 
“Glue Code” 
“Step Definitions” 
System Under Test 
17 
Hand Coded 
Hand Coded
Bypass GUI? 
Domain Language 
Scenario 
Test Fixture 
Bypass GUI, test 
core system directly 
GUI 
18 
Under-the-GUI API
19
Demo: 
building a new feature 
with StoryText 
20
 Open Source 
 Development paid for by Jeppesen 
 supports Java Swing, Eclipse RCP, PyGTK, Tkinter, wxPython 
 http://texttest.org 
21
TextTest tests have two parts 
Use Case GUI Log 
List of user actions: 
Domain language 
Recorded text: 
Contents of GUI 
22
TextTest - test fixtures 
 Create “use case” part of text by Record session in UI 
 Name your actions: snippets of domain language 
 UI Map - domain language mapped to actions 
23
Compose a Domain Language 
24 
 Group several user actions and name them 
 Match the language of the specification workshop 
 Re-usable terms for many tests
Record the Test Fixture/Step definitions 
Use Case 
(one per test) 
“UI Map” + “shortcuts” 
(shared by whole suite) 
System Under Test 
25 
Recorded 
Configured
StoryText tests 
Use Case GUI Log 
List of user actions: 
Domain language 
Recorded text: 
Contents of GUI 
26
The GUI log 
 “Assert” part of the test 
 Auto-generated by 
StoryText 
 ASCII art represents UI 
state 
27
StoryText tests 
Use Case GUI Log 
Plain Text: search, store, manipulate, diff, version... 
28
29
Sample Use-Case : 
Undo Service Type changes 
30 
open default plan and show rosters 
change service type of activity JPO 2537 for 
Brogan to M 
undo 
wait for completion of undo 
close and discard changes
Crew Management System 
31
Assert Everything by default 
 Log of absolutely everything that changes in the GUI 
 Each test defines filters to focus on interesting parts 
 Often catch errors the test wasn’t designed to find 
32
Limitations of the approach 
 Only supports certain GUI libraries 
 Maintainability of tests depends on good test 
design 
◦ filter GUI log carefully 
33
Conclusions 
 Specification by Example - automating Domain 
Language scenarios needs fixture code 
◦ TextTest “records” the fixtures 
 GUI intensive applications - need to check 
carefully what’s on the screen 
◦ TextTest takes “screen shots” as ASCII art 
34

Geoff & Emily Bache - Specification By Example With GUI Tests-How Could That Work - EuroSTAR 2013

  • 1.
    Specification by Examplewith GUI tests - How could that work? Emily Bache, Bache Consulting & Pagero Geoff Bache, Jeppesen @esconfs #esconfs
  • 3.
    Specification by Example with Rich-Client application? 3
  • 4.
    Jeppesen  Agiletransition underway  next-generation Crew Management System 4
  • 5.
  • 6.
  • 7.
    Specification by Example  Gojko Adzic’s book  Collaborative workshops  Define Example Scenarios BEFORE build code 7
  • 8.
    Agile Requirements UserStory + Conversation + Examples = Requirement From “Agile Testing” by Crispin, Gregory 8 aka Scenarios
  • 9.
    Scenario -> Regressiontest  BEFORE code is written, it’s a requirement specification  AFTER code is written it’s a regression test Important to preserve the language & format 9 Living Documentation
  • 10.
    GUI testing withRecord - Replay 10
  • 11.
    Recorded GUI Tests  Click around the GUI like a user would  Record a script  Re-play the script to regression test 11 Assumes the GUI is already built
  • 12.
    Recorded Scripts Easyto create, hard to maintain 12
  • 13.
    Page Object Pattern 13 Test Case Scripts Hand Coded Page Objects Hand Coded System Under Test
  • 14.
    GUI testing withCucumber, Fitnesse etc 14
  • 15.
    Using Cucumber Feature http://cukes.info Step Definitions System Under Test (SUT)
  • 16.
    Using Fitnesse 16 http://fitnesse.org
  • 17.
    “Domain Language” Tests Domain Language Scenario or Table Test Fixture “Glue Code” “Step Definitions” System Under Test 17 Hand Coded Hand Coded
  • 18.
    Bypass GUI? DomainLanguage Scenario Test Fixture Bypass GUI, test core system directly GUI 18 Under-the-GUI API
  • 19.
  • 20.
    Demo: building anew feature with StoryText 20
  • 21.
     Open Source  Development paid for by Jeppesen  supports Java Swing, Eclipse RCP, PyGTK, Tkinter, wxPython  http://texttest.org 21
  • 22.
    TextTest tests havetwo parts Use Case GUI Log List of user actions: Domain language Recorded text: Contents of GUI 22
  • 23.
    TextTest - testfixtures  Create “use case” part of text by Record session in UI  Name your actions: snippets of domain language  UI Map - domain language mapped to actions 23
  • 24.
    Compose a DomainLanguage 24  Group several user actions and name them  Match the language of the specification workshop  Re-usable terms for many tests
  • 25.
    Record the TestFixture/Step definitions Use Case (one per test) “UI Map” + “shortcuts” (shared by whole suite) System Under Test 25 Recorded Configured
  • 26.
    StoryText tests UseCase GUI Log List of user actions: Domain language Recorded text: Contents of GUI 26
  • 27.
    The GUI log  “Assert” part of the test  Auto-generated by StoryText  ASCII art represents UI state 27
  • 28.
    StoryText tests UseCase GUI Log Plain Text: search, store, manipulate, diff, version... 28
  • 29.
  • 30.
    Sample Use-Case : Undo Service Type changes 30 open default plan and show rosters change service type of activity JPO 2537 for Brogan to M undo wait for completion of undo close and discard changes
  • 31.
  • 32.
    Assert Everything bydefault  Log of absolutely everything that changes in the GUI  Each test defines filters to focus on interesting parts  Often catch errors the test wasn’t designed to find 32
  • 33.
    Limitations of theapproach  Only supports certain GUI libraries  Maintainability of tests depends on good test design ◦ filter GUI log carefully 33
  • 34.
    Conclusions  Specificationby Example - automating Domain Language scenarios needs fixture code ◦ TextTest “records” the fixtures  GUI intensive applications - need to check carefully what’s on the screen ◦ TextTest takes “screen shots” as ASCII art 34