28
BDD for Web Applications Thomas Lundström, Softhouse @thomaslundstrom TelecomCity DevCon, Karlskrona September 23, 2010

Bdd for Web Applications at TelecomCity DevCon 2010

Embed Size (px)

DESCRIPTION

Presentation for the conference TelecomCity DevCon September 23, 2010

Citation preview

Page 1: Bdd for Web Applications at TelecomCity DevCon 2010

BDD for Web Applications

Thomas Lundström, Softhouse@thomaslundstrom

TelecomCity DevCon, KarlskronaSeptember 23, 2010

Page 2: Bdd for Web Applications at TelecomCity DevCon 2010

Agenda

• What is BDD?

• BDD for web applications

• BDD + Traditional QA?

http://www.flickr.com/photos/puntodevista/84796578/

Page 3: Bdd for Web Applications at TelecomCity DevCon 2010

BDD

• What is BDD?

Page 4: Bdd for Web Applications at TelecomCity DevCon 2010

BDD

Stakeholders

* “BDD aims to bridge the gap between the differing views of computer systems held by Business users and Technologists. It is deeply rooted in the success of TDD and is influenced by ideas like Domain Driven Design. Its focus is on minimizing the hurdles between specification, design, implementation and confirmation of the behaviour of a system.”

http://www.flickr.com/photos/zunami/3709268689/

Page 5: Bdd for Web Applications at TelecomCity DevCon 2010

BDDReqs

* Golden triangle between analyst’s requirements, acceptance tests from the test department and the “Done” criteria for a feature used by the developers

* Team effort - Analyst - Tester - Developer/Architect

Test Done

http://www.flickr.com/photos/qthomasbower/3426242870/

Page 6: Bdd for Web Applications at TelecomCity DevCon 2010

User stories - example

As a public userI want to be able to view messagesSo that I can see what my friends think

BDD builds upon the conversation taking place in user stories and acceptance criteria.

Context: comments for e.g. articles on a news site

Page 7: Bdd for Web Applications at TelecomCity DevCon 2010

Acc. criteria - example

Given that there are 3 messages in the comment pageWhen I view the comment pageThen I should see 3 messages

Given that the comment page is emptyWhen I view the comment pageThen I should see 0 messages

Acceptance criteria defines if the software is done

One story - Many acceptance criteria

This is only 2 of the possible acceptance criteria for the story

Page 8: Bdd for Web Applications at TelecomCity DevCon 2010

BDD(If we work with iterations - the same thing applies if we work pull-based)

Before we do something, we need to agree upon what we should deliver = before stories are accepted into the iteration, we define the acceptance criteria for the story

Based on the acceptance criteria and our estimations, we include X number of stories to deliver in the iteration

Important: we can’t commit to deliver something unless we know what to deliver = be thorough in splitting a story in acceptance criteria

How to use BDD in an iteration?

Page 9: Bdd for Web Applications at TelecomCity DevCon 2010

BDD

Vocabulary

* Focus on vocabulary - user stories - acceptance criteria

Ubiquitous language!

http://www.flickr.com/photos/altemark/337248947/

Page 10: Bdd for Web Applications at TelecomCity DevCon 2010

BDD

Outside-in

http://www.flickr.com/photos/redcherryhill/389325062/

* Outside-in - onion - use the words of the user, not the programmer

* Connection DDD - BDD: use ubiquitous language when specifying the user words

* Unit-level tests are still needed

Page 11: Bdd for Web Applications at TelecomCity DevCon 2010

BDDThis is a tool in your toolbox. Use as needed.

No silver bullet

http://www.flickr.com/photos/williamhook/1506578592/

Page 12: Bdd for Web Applications at TelecomCity DevCon 2010

Why BDD?As said previously: The Holy Grail :)

This is what I find the most interesting with the whole discussion about BDD.

- executable specifications- focus on requirements - everything builds upon user stories/acceptance criteria

http://www.flickr.com/photos/22280677@N07/3342653727/

Page 13: Bdd for Web Applications at TelecomCity DevCon 2010

Tools

@deurell, http://twitpic.com/iqp9c

Ruby: Cucumber, RSpec

Java: JBehave, cuke4duke

.NET: NBehave, cuke4nuke

Page 14: Bdd for Web Applications at TelecomCity DevCon 2010

ToolsFocus on process - not tech!

Process

http://www.flickr.com/photos/nostri-imago/3137422976/

Page 15: Bdd for Web Applications at TelecomCity DevCon 2010

Tool architecture

Language

Runner

Glue layer

SUT

Yellow = the part of the BDD stack that you write

Page 16: Bdd for Web Applications at TelecomCity DevCon 2010

BDD + Web apps

http://www.flickr.com/photos/rubyran2626/296913361/

Perfect marriage!

All web apps use the same tech to communicate

HTML (+ javascript) is the lingua franca for web development

Page 17: Bdd for Web Applications at TelecomCity DevCon 2010

cuke4duke + seleniumGherkin

cuke4duke

Selenium + WebDriver

HTML + js

Hooks

WebDriver = one of e.g. HtmlUnit, Firefox, Chrome, IE etc.

Hooks = cuke4duke methods + the page object pattern

Page 18: Bdd for Web Applications at TelecomCity DevCon 2010

Demo

• Domain: Comment functionality

• Adding

• Viewing

• (In the future, it’s possible to add moderation, tagging etc)

Page 19: Bdd for Web Applications at TelecomCity DevCon 2010

Current functionality

• Viewing comments

Demo: current functionality

Page 20: Bdd for Web Applications at TelecomCity DevCon 2010

New iteration

• New feature: adding comments

Demo: add comments

* new feature* new steps* implement steps* implement web app

Page 21: Bdd for Web Applications at TelecomCity DevCon 2010

New iteration

• New feature: paging

Page 22: Bdd for Web Applications at TelecomCity DevCon 2010

CI environment

• Run acceptance criteria in the build

How to include this into the regular CI env?

Depends on what you run

Here: easy with maven2

In .NET land, e.g. msbuild or Ant/Java, let the build script launching the acceptance criteria run

Results from the acc criteria run should be output to html so that we know how far we’ve gotten

Page 23: Bdd for Web Applications at TelecomCity DevCon 2010

Test automation

• BDD vs. Test automation?

Is there a difference between BDD and the test automation we’ve previously used?

- It depends on how the test automation was done - with BDD, we’ve got test automation aligned with (that are) the requirements!

Earlier: test automation prone to breakage. Why?- dev changes stuff (button names etc) that test automation uses (fixed by running everything in the build; everyone is in charge of the build, instead of only the test dept)- Requirements churn (we can’t guard from that)- Unstable tools (no guard here either)

Page 24: Bdd for Web Applications at TelecomCity DevCon 2010

Test automation - imperative/declarative

http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/

Page 25: Bdd for Web Applications at TelecomCity DevCon 2010

Test automation - imperative/declarative

http://www.benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories/

BREAK

Page 26: Bdd for Web Applications at TelecomCity DevCon 2010

Test in a BDD process

• “You can not inspect quality into the product; it’s already there”- W. Edwards Deming

Shift in viewpoint: previously, we

We use testers to transform high-level stories to “do this, do that” specs, which preferably are automated. It’s their speciality to find these thngs!

Page 27: Bdd for Web Applications at TelecomCity DevCon 2010

Test in a BDD process

Testers can go from performing manual script labour to do more useful stuff

- exploratory testing- helping devs & analysts analyse the problem- Performance testing

The competence of the testers i.e. translation of abstract Reqs -> hands-on runnables is used when defining acceptance criteria

http://en.wikipedia.org/wiki/File:Systems_Engineering_Process_II.gif

Page 28: Bdd for Web Applications at TelecomCity DevCon 2010

Thanks!

• Thomas Lundström, Softhouse

[email protected]

• Twitter: @thomaslundstrom

• http://blog.thomaslundstrom.com