atdd mit concordion und webdriver€¦ · atdd mit concordion und webdriver © opitz consulting...
TRANSCRIPT
© OPITZ CONSULTING GmbH 2011 Seite 1ATDD mit Concordion und WebDriver
ATDD mit Concordion und WebDriver
© OPITZ CONSULTING GmbH 2011 Seite 2ATDD mit Concordion und WebDriver
Müller, Torsten
OPITZ CONSULTING Berlin GmbH
Berlin, 07 April 2011
ATDD mit Concordion und WebDriver
© OPITZ CONSULTING GmbH 2011 Seite 3ATDD mit Concordion und WebDriver
Einleitung
“ATDD is hard work”
“The complexity and effort
of automating acceptance tests
easily matches – and often outweighs –
that of implementing the story itself.”
JASON GORMAN: ANTWORT AUF BRIAN MARICK: BARRIERS TO ACCEPTANCE-TEST DRIVEN DESIGN
http://www.exampler.com/blog/2008/08/19/barriers-to-acceptance-test-driven-design
© OPITZ CONSULTING GmbH 2011 Seite 4ATDD mit Concordion und WebDriver
Agenda
1. Akzeptanztest-getriebene Entwicklung (ATDD)
2. Tools
Concordion
WebDriver
3. (Best?) Practices
WebDriver
Concordion
Test Automation
© OPITZ CONSULTING GmbH 2011 Seite 5ATDD mit Concordion und WebDriver
1 Akzeptanztest-getriebene Entwicklung (ATDD)
© OPITZ CONSULTING GmbH 2011 Seite 6ATDD mit Concordion und WebDriver
Begriffsdefinition
Entwicklungspraxis, in der
die funktionalen Anforderungen (Akzeptanzkriterien)
einer User Story
als konkrete und automatisierbare
(praxisrelevante) Beispiele
vor der eigentlichen Entwicklung der Story
selber geschrieben werden.
WIECHMANN ET AL.: ATDD KURZ ERKLÄRT – DIE RICHTIGEN DINGE ENTWICKELN
http://www.projekt-log.de/agile_softwareentwicklung/atdd-in-a-nutshell/
© OPITZ CONSULTING GmbH 2011 Seite 7ATDD mit Concordion und WebDriver
Gegenstand
„Specification by Example“
„Example Driven Development“
GOJKO ADZIC: SPECIFYING WITH EXAMPLES
http://gojko.net/2008/11/04/specifying-with-examples/
© OPITZ CONSULTING GmbH 2011 Seite 8ATDD mit Concordion und WebDriver
Prozess
DAVID PETERSON: STORY DELIVERY LIFECYCLE
http://www.concordion.org/memo/StoryDeliveryLifecycle.pdf
© OPITZ CONSULTING GmbH 2011 Seite 9ATDD mit Concordion und WebDriver
Abgrenzung: ATDD und Abnahmetests
Abnahmetest oder auch User Akzeptanztest (UAT)
Fokus: Test der gelieferten Software durch den Kunden bzw. Auftraggeber
Ziel: Abnahme der Software
Akzeptanztest-getriebene Entwicklung
Fokus: Kommunikation zwischen Product Owner und Entwicklungsteam
Ziel: Entwicklung der „richtigen“ Software
© OPITZ CONSULTING GmbH 2011 Seite 10ATDD mit Concordion und WebDriver
Abgrenzung: ATDD und TDD
LASSE KOSKELA: ACCEPTANCE TDD EXPLAINED
http://www.methodsandtools.com/archive/archive.php?id=72
© OPITZ CONSULTING GmbH 2011 Seite 11ATDD mit Concordion und WebDriver
Anwendungsbereiche
NIGEL CHARMAN: WHAT TYPES OF APPLICATION CAN I TEST WITH CONCORDION?
http://tutansblog.blogspot.com/2009/06/what-types-of-application-can-i-test.html
© OPITZ CONSULTING GmbH 2011 Seite 12ATDD mit Concordion und WebDriver
Automatisierung
“Acceptance tests should run
in an environment
as close to the
production environment
as possible.”
© OPITZ CONSULTING GmbH 2011 Seite 13ATDD mit Concordion und WebDriver
Tool-Einsatz
WebDriver
Concordion
© OPITZ CONSULTING GmbH 2011 Seite 14ATDD mit Concordion und WebDriver
2Tools
© OPITZ CONSULTING GmbH 2011 Seite 15ATDD mit Concordion und WebDriver
2.1Concordion
© OPITZ CONSULTING GmbH 2011 Seite 16ATDD mit Concordion und WebDriver
Concordion
“Lets you write business tests that don't assume
a particular implementation.”
PROJECT WEBSITE
http://www.concordion.org/
© OPITZ CONSULTING GmbH 2011 Seite 17ATDD mit Concordion und WebDriver
Funktionsweise
PROJECT WEBSITE
http://www.concordion.org/
© OPITZ CONSULTING GmbH 2011 Seite 18ATDD mit Concordion und WebDriver
Funktionsweise
PROJECT WEBSITE
http://www.concordion.org/
© OPITZ CONSULTING GmbH 2011 Seite 19ATDD mit Concordion und WebDriver
Beispiel – Spezifikation
© OPITZ CONSULTING GmbH 2011 Seite 20ATDD mit Concordion und WebDriver
Beispiel – Instrumentierung
© OPITZ CONSULTING GmbH 2011 Seite 21ATDD mit Concordion und WebDriver
Beispiel – Fixture
© OPITZ CONSULTING GmbH 2011 Seite 22ATDD mit Concordion und WebDriver
Beispiel – JUnit-Integration
ConcordionRunner
ConcordionBuilder
© OPITZ CONSULTING GmbH 2011 Seite 23ATDD mit Concordion und WebDriver
Screenshot Extension
attach screenshots to help
diagnose test failures
add screenshots to the output
for documentation purposes
Erweiterungen: Screenshot Extension
© OPITZ CONSULTING GmbH 2011 Seite 24ATDD mit Concordion und WebDriver
Logging Tooltip Extension
provide more insight into what
the tests are actually doing
Erweiterungen: Logging Tooltip Extension
© OPITZ CONSULTING GmbH 2011 Seite 25ATDD mit Concordion und WebDriver
2.2WebDriver
© OPITZ CONSULTING GmbH 2011 Seite 26ATDD mit Concordion und WebDriver
WebDriver
“WebDriver is a tool
for automating testing web applications,
and in particular
to verify that they work as expected.”
“It aims to provide a friendly API that’s
easy to explore and understand,
which will help make your tests
easier to read and maintain.”
PROJECT WEBSITE
http://seleniumhq.org/docs/03_webdriver.html
© OPITZ CONSULTING GmbH 2011 Seite 27ATDD mit Concordion und WebDriver
Beispiel
© OPITZ CONSULTING GmbH 2011 Seite 28ATDD mit Concordion und WebDriver
3(Best?) Practices
© OPITZ CONSULTING GmbH 2011 Seite 29ATDD mit Concordion und WebDriver
3.1WebDriver
© OPITZ CONSULTING GmbH 2011 Seite 30ATDD mit Concordion und WebDriver
WebDriver Practices
Name Everything
Waiting, Waiting, Waiting…
Turn UI Testing into API Testing
Always Have A Plan B. And A Plan C. (And D…)
Take Screenshots If Something Goes Wrong
Use Diagnostic Logging
THOMAS SCHRANTZ: UI AUTOMATION: TRICKS AND TRAPS
http://www.mathpirate.net/log/2009/12/23/ui-automation-tricks-and-traps/
© OPITZ CONSULTING GmbH 2011 Seite 31ATDD mit Concordion und WebDriver
„Name Everything”
© OPITZ CONSULTING GmbH 2011 Seite 32ATDD mit Concordion und WebDriver
„Waiting, Waiting, Waiting…”
© OPITZ CONSULTING GmbH 2011 Seite 33ATDD mit Concordion und WebDriver
„Waiting, Waiting, Waiting…”
© OPITZ CONSULTING GmbH 2011 Seite 34ATDD mit Concordion und WebDriver
„Waiting, Waiting, Waiting…”
Window Licker (http://code.google.com/p/windowlicker/)
© OPITZ CONSULTING GmbH 2011 Seite 35ATDD mit Concordion und WebDriver
„Turn UI Testing into API Testing”
Introduce Page and (optional) Site Objects
© OPITZ CONSULTING GmbH 2011 Seite 36ATDD mit Concordion und WebDriver
„Turn UI Testing into API Testing”: Page Objects
SIMON STEWARD: PAGE OBJECTS
http://code.google.com/p/selenium/wiki/PageObjects
© OPITZ CONSULTING GmbH 2011 Seite 37ATDD mit Concordion und WebDriver
„Turn UI Testing into API Testing”: Page Objects
Hide low level implementation details
Methods represent the services that the page offers
loginPage.loginAs(String user, String credentials);
searchPage.searchFor(String query);
Methods return other page objects
SearchResultsPage resultsPage =
searchPage.searchFor(String query);
Different results for the same action are modeled
as different methods
RefineSearchPage refineSearchPage =
searchPage.searchForButExpectNoMatches(String query);
© OPITZ CONSULTING GmbH 2011 Seite 38ATDD mit Concordion und WebDriver
Page Objects: WebDriver Support
PageFactory(Package org.openqa.selenium.support)
LoadableComponent & SlowLoadableComponent(Package org.openqa.selenium.support.ui)
© OPITZ CONSULTING GmbH 2011 Seite 39ATDD mit Concordion und WebDriver
„Always Have A Plan B. And A Plan C.”
JavascriptExecutor(Package org.openqa.selenium)
© OPITZ CONSULTING GmbH 2011 Seite 40ATDD mit Concordion und WebDriver
„Take Screenshots”
TakesScreenshot(Package org.openqa.selenium)
© OPITZ CONSULTING GmbH 2011 Seite 41ATDD mit Concordion und WebDriver
„Diagnostic Logging”
EventFiringWebDriver & WebDriverEventListener(Package org.openqa.selenium.support.events)
© OPITZ CONSULTING GmbH 2011 Seite 42ATDD mit Concordion und WebDriver
3.2Concordion
© OPITZ CONSULTING GmbH 2011 Seite 43ATDD mit Concordion und WebDriver
Concordion Practices
“The closer your acceptance tests
are to the business rules,
the more stable they are.”
GOJKO ADZIC: HOW TO IMPLEMENT UI TESTING WITHOUT SHOOTING YOURSELF IN THE FOOT
http://gojko.net/2010/04/13/how-to-implement-ui-testing-without-shooting-yourself-in-the-foot-2/
DAVID PETERSON: CONCORDION – HINTS AND TIPS
http://www.concordion.org/Technique.html
© OPITZ CONSULTING GmbH 2011 Seite 44ATDD mit Concordion und WebDriver
Concordion Practices
Think Given-When-Then
Write Specifications, not Scripts
Use S.M.A.R.T. Examples
Think in Goals, Tasks and Actions
Evolve a Scripting DSL
DAVID PETERSON: CONCORDION – HINTS AND TIPS
http://www.concordion.org/Technique.html
© OPITZ CONSULTING GmbH 2011 Seite 45ATDD mit Concordion und WebDriver
„Think Given-When-Then“
Scenario: <A scenario specific goal>
GIVEN <something that needs to have happened or be true>
WHEN <some task I must do>
THEN <some way I know I've achieved my goal>
© OPITZ CONSULTING GmbH 2011 Seite 46ATDD mit Concordion und WebDriver
„Write Specifications, not Scripts“
Scenario: Search for the Concordion homepage
Given I am at http://google.com
When I enter "concordion" into the search field and click "Search"
Then the top result should say "Concordion”
Better Scenario: Search for the Concordion homepage
When I search for "concordion"
Then the top result should say "Concordion"
© OPITZ CONSULTING GmbH 2011 Seite 47ATDD mit Concordion und WebDriver
„Use S.M.A.R.T. Examples“
SPECIFIC
Examples are explicitly defined and definite.
MEASURABLE
The result is observable and quantifiable.
ACHIEVABLE
Examples describe a realistic scenario.
RELEVANT
Examples are related to the particular story.
TIME-BOUND
The result can be observed in a defined Time.
NARESH JAIN: ACCEPTANCE TEST DRIVEN DEVELOPMENT
http://www.slideshare.net/nashjain/acceptance-test-driven-development-350264
© OPITZ CONSULTING GmbH 2011 Seite 48ATDD mit Concordion und WebDriver
„Think in Goals, Tasks and Actions“
GOAL: What we’re trying to achieve which has one or more…
TASKS: The high-level work-item that we complete to fulfill the
goal, each having one or more…
ACTIONS: The specific steps or interactions we execute to complete
the task.
GOALS, TASKS Spezifikation
ACTIONS Fixture
MARCANO, ANTONY: A BIT OF UCD FOR BDD & ATDD: GOALS -> TASKS -> ACTIONS
http://antonymarcano.com/blog/2011/03/goals-tasks-action/
© OPITZ CONSULTING GmbH 2011 Seite 49ATDD mit Concordion und WebDriver
„Evolve a Scripting DSL“
DAVID PETERSON: WHAT DO I MEAN BY A „SCRIPTING DSL“?
http://blog.davidpeterson.co.uk/2008/02/what-do-i-mean-by-scripting-dsl.html
© OPITZ CONSULTING GmbH 2011 Seite 50ATDD mit Concordion und WebDriver
„Evolve a Scripting DSL“
GIVEN
Encapsulate test data creation
Object Mother, Test Data Builder
Make It Easy (http://code.google.com/p/make-it-easy/)
WHEN
Turn UI Testing into API Testing
Page Objects (http://code.google.com/p/selenium/wiki/PageObjects)
THEN
Encapsulate Assertions
Hamcrest (http://www.code.google.com/p/hamcrest/)
© OPITZ CONSULTING GmbH 2011 Seite 51ATDD mit Concordion und WebDriver
3.3Test Automation
© OPITZ CONSULTING GmbH 2011 Seite 52ATDD mit Concordion und WebDriver
Test Automation
VEGARD HARTMANN: SUCCEEDING WITH WEBTESTING USING WEBDRIVER
http://open.bekk.no/wp-content/uploads/2010/03/succeeding-with-webtesting-using-webdriver.pdf
© OPITZ CONSULTING GmbH 2011 Seite 53ATDD mit Concordion und WebDriver
Test Automation Practices
Use Independent Tests
Cleanup, Setup, Test, Teardown
Use Non-Production code for Setup/Teardown
Don't rely on external systems that you don't control
Provide Feedback If Something Goes Wrong
NARESH JAIN: PATTERNS AND ANTI-PATTERNS: ACCEPTANCE TESTING WITH FITNESSE
http://blogs.agilefaqs.com/2007/08/25/patterns-and-anti-patterns-acceptance-testing-with-fitnesse/
© OPITZ CONSULTING GmbH 2011 Seite 54ATDD mit Concordion und WebDriver
Fragen und Antworten
© OPITZ CONSULTING GmbH 2011 Seite 55ATDD mit Concordion und WebDriver
Referenzen
© OPITZ CONSULTING GmbH 2011 Seite 56ATDD mit Concordion und WebDriver
Referenzen
Adzic, Gojko:
Bridging the Communication Gap: Specification by Example and
Agile Acceptance Testing
London : Neuri Limited; 2009. ISBN 978-0955683619
Freeman, Steve; Pryce Nat:
Growing Object-Oriented Software, Guided by Tests
Amsterdam : Addison-Wesley Longman; 2009.
ISBN 978-0321503626
© OPITZ CONSULTING GmbH 2011 Seite 57ATDD mit Concordion und WebDriver
Referenzen
Adzic, Gojko: How to implement UI testing without shooting
yourself in the foot
http://gojko.net/2010/04/13/how-to-implement-ui-testing-without-
shooting-yourself-in-the-foot-2/
Adzic, Gojko: Specifying With Examples
http://gojko.net/2008/11/04/specifying-with-examples/
Charman, Nigel:
What types of application can I test with Concordion?
http://tutansblog.blogspot.com/2009/06/what-types-of-application-
can-i-test.html
Gorman, Jason: Antwort auf
Marick, Brian: Barriers to acceptance-test driven design
http://www.exampler.com/blog/2008/08/19/barriers-to-acceptance-
test-driven-design
© OPITZ CONSULTING GmbH 2011 Seite 58ATDD mit Concordion und WebDriver
Referenzen
Hartmann, Vegard:
Succeeding with webtesting – Using WebDriver
http://open.bekk.no/wp-content/uploads/2010/03/succeeding-with-
webtesting-using-webdriver.pdf
Jain, Naresh: Acceptance Test Driven Development
http://www.slideshare.net/nashjain/acceptance-test-driven-
development-350264
Jain, Naresh: Patterns and Anti-Patterns: Acceptance Testing with
FitNesse
http://blogs.agilefaqs.com/2007/08/25/patterns-and-anti-patterns-
acceptance-testing-with-fitnesse
Koskela, Lasse : Acceptance TDD Explained
http://www.methodsandtools.com/archive/archive.php?id=72
© OPITZ CONSULTING GmbH 2011 Seite 59ATDD mit Concordion und WebDriver
Referenzen
Marcano, Antony:
A bit of UCD for BDD & ATDD: Goals -> Tasks -> Actions
http://antonymarcano.com/blog/2011/03/goals-tasks-action/
Marcano, Antony:
Acceptance tests are more A+S than T+G
http://www.testingreflections.com/node/view/6704
Peterson, David: Concordion – Hints and Tips
http://www.concordion.org/Technique.html
Peterson, David: Story Delivery Lifecycle
http://www.concordion.org/memo/StoryDeliveryLifecycle.pdf
Peterson, David: What do I mean by a „Scripting DSL“?
http://blog.davidpeterson.co.uk/2008/02/what-do-i-mean-by-
scripting-dsl.html
© OPITZ CONSULTING GmbH 2011 Seite 60ATDD mit Concordion und WebDriver
Referenzen
Pryce, Nat:
Test Data Builders: an alternative to the Object Mother pattern
http://nat.truemesh.com/archives/000714.html
Schrantz, Thomas: UI Automation: Tricks and Traps
http://www.mathpirate.net/log/2009/12/23/ui-automation-tricks-and-
traps
Steward, Simon: Page Objects
http://code.google.com/p/selenium/wiki/PageObjects
Wiechmann, Robert et al.:
ATDD kurz erklärt – Die richtigen Dinge entwickeln
http://www.projekt-log.de/agile_softwareentwicklung/atdd-in-a-
nutshell/
© OPITZ CONSULTING GmbH 2011 Seite 61ATDD mit Concordion und WebDriver
Referenzen
Concordion: http://www.concordion.org/ Logging Tooltip Extension
http://www.concordion.org/extensions/LoggingTooltipExtension.html
Screenshot Extension
http://www.concordion.org/extensions/ScreenshotExtension.html
WebDriver: http://seleniumhq.org/docs/03_webdriver.html
Make It Easy: http://code.google.com/p/make-it-easy/
Hamcrest: http://www.code.google.com/p/hamcrest/
Window Licker http://code.google.com/p/windowlicker/