High quality technical screencasts created by
experts on the latest and most important
technologies. Buy access to a single series or
subscribe for as little as $19 a month.
tekpub.com
ASP.NET MVC
Ayende Rahien
Rob Conery
jQuery
Dave Ward
Ruby on Rails
ASP.NET Ajax
LINQ
nHibernate
About me
TechTalk is a software
development and consulting
company with ~60 people located
in Vienna, Budapest and Zürich.
We focus on Scrum and .NET.
Jonas Bandi
At TechTalk since 2009
Committer to SpecFlow
http://blog.jonasbandi.net
Twitter: @jbandi
The audience?
• Who is practicing agile
Development?
• Who is practicing TDD?
• Wo is doing Acceptance Test Driven
Development or Behavior Driven
Development?
• Wo is using Cucumber, Fitnesse,
Concordion, NBehave or a similar
tool?
• Who knows SpecFlow?
Agenda
• The Communication Gap: A reason why
we are failing
• Agile software development promises
improvement
• BDD as a possible approach to improve
• SpecFlow as tool that supports BDD
• Advanced topics and loose ends
Let´s discuss!
"We're still figuring
this stuff out.
All of us."
- Jay Fields
Thoughts on developer Testing:
http://blog.jayfields.com/2009/02/thoughts-on-developer-testing.html
"I believe that the hardest
part of software projects,
the most common source
of project failure, is
communication with the
customers and users of
that software."
- Martin Fowler,
DSL Book
Providing Business Value?
• Only 20% of all delivered features are
actually used?
• Something is wrong!
• We can profit tremendously when we
improve in
• requirements gathering
• transporting them successfully to the
implementation
Where errors are introduced
Source: James Martin, An Information Systems Manifesto
Fighting Errors?
• Traditional developer
testing focuses on code
and maybe design
• Testing requirements is
hardly ever a topic
• We can profit
tremendously when we
improve in requirements
gathering.
Streaming requirements
• Not all of the
requirements are
delivered upfront
• Requirements are
delivered just in time
• Incrementally reveal
details just-in-time
• Pull instead of push
• Embrace Change
The promised benefits
• Constant feedback and
priorization by the Stakeholder
– Build those features that are
needed and useful
• Features have a much shorter
through-put time
– Allows validation of requirements
Remaining challenges
• How to communicate requirements
effectively?
• How to ensure that requirements are
understood and implemented correctly?
Requirements == Tests
As formality increases,
tests and requirements
become indistinguishable.
At the limit, tests and
requirements are
equivalent.
Equivalence Hypothesis
(Martin, Melnik, 2008)
Executable test-based
specifications
Pic: Martin/Melnik: Requirements
and Tests
Behavor Driven Development:
An attempt to fit it all together
BDD
Behavior Driven
Development
TDD
Test Driven Development
DDD
Domain Driven Design
ATDD
Acceptance Test Driven
Development
User Stories
Specification
by Example
Definition of
Done
Outside-In
Development
DSL
Domain Specific Language
The real Goal
Pic: http://www.projectcartoon.com/
• Test Driven Development is about
Design
• Acceptance Test Driven
Development is about
Specification and Communication
• Writing acceptance tests early
– is a requirements engineering
technique
– builds a common understanding
– defines clear goals and a
common definition of done
Specification by Example
• Abstract requirements and
specifications are not a good tool
for communication.
• Concrete examples are much
better.
• Usually examples are not
formalized and not shared.
Examples Tests
Requirements
are composed of
elaborate verify & validate
_
Example: User Stories
Detailgrad
Why?
How?
Actor-Goals
Actor-Goals
Epics
Epics
Business Goals
Business Goals
User Stories
User Stories
Acceptance
Acceptance
Criteria
Amount of Work
Predictability
Code
As a potential customer
I want to search for books by a simple string
So that I can easily allocate books by
something I remember from them.
As a potential customer
I want to place books into my shopping basket
So that I can order several books at once.
Communi-
cation
Gap!
_
Example: Acceptance Criteria
Detailgrad
Why?
How?
Actor-Goals
Actor-Goals
Epics
Epics
Business Goals
Business Goals
User Stories
User Stories
Acceptance
Acceptance
Criteria
Amount of Work
Predictability
Code
As a potential customer
I want to search for books by a simple string
So that I can easily allocate books by
something I remember from them.
Author of book should be matched.
Space should be treated as multiple OR search.
Search string should be at least 4 characters.
Items should be matched only once.
Title of book should be matched.
Communi-
cation
Gap!
Examples as Acceptance Criteria
As a potential customer
I want to search for books by a simple string
So that I can easily allocate books by
something I remember from them.
Title of book should be matched.
Given the following books
| Author | Title |
| Ted Pattison | Inside Windows SharePoint Services |
| Martin Fowler| Patterns of Enterprise Architecture |
| Eric Evans | Domain Driven Design |
When I perform a simple search on “Domain”
Then the book list should only contain: “Domain Driven Design”
Examples
• Enable developers and testers to
communicate efficiently with business
people
• Provide enough information for developers
to implement and for testers to verify
• Realistic examples contain precise
information and ask for precise answers
• Are a way to test specifications!
• … express a shared understanding
Shared understanding
• Terminology and
abstractions of business
• Concrete enough for
developers
• Business readable
• Bound to implementation
• Consistent
Outside-In Development
• Always start with a Story
• What development
should focus on:
– Providing business value
– Satisfying stakeholder
needs
– Software that matters
– Consumable software
1
2
3
4
5
Behavor Driven Development:
An attempt to fit it all together
BDD
Behavior Driven
Development
TDD
Test Driven Development
DDD
Domain Driven Design
ATDD
Acceptance Test Driven
Development
User Stories
Specification
by Example
Definition of
Done
Outside-In
Development
DSL
Domain Specific Language
SpecFlow
• Open-source BDD tool for .NET
– www.specflow.org
– github.com/techtalk/SpecFlow
• Focus on high level behavior: features /
acceptance tests
• Focus on story-style plain text
specifications
• Using Gherkin as DSL for specifications
• Uses existing testing frameworks for
execution (Nunit, MSTest, xUnit)
– VisualStudio / Build integration
www.specflow.org
SpecFlow History
• SpecFlow was founded in late 2009 by
TechTalk
• Goals:
– A pragmatic BDD tool for .NET
– Provide a frictionless experience for .NET
environments
– Use existing tools: VisualStudio, UnitTest-
Frameworks
• SpecFlow is used in several projects by
TechTalk
www.specflow.org
Gherkin
• A language (DSL) for story-style
plain text specifications
– “Given“-“When“-“Then“
• Rooted in the Ruby World:
Cucumber
• Business readable / writeable
• Sufficient formality
– Enable automation
– Executable specification
• http://github.com/aslakhellesoy/gherkin/ www.cukes.info
Gherkin Features
• User stories are
requirements
• A single scenario is an
example that drives the
development
• Scenarios define a common
definition of „done“
• All scenarios together build
the acceptance criteria of
the story/feature
Automated scenarios …
• … describe what the system should do
• … are business readable
• … establish a common vocabulary
• … capture a shared set of examples
• … enable communication
• … are bound to the implementation
• … are executable
• … express a shared understanding
Acceptance Tests vs. Unit Tests
• Acceptance Tests
• Business oriented
• What?
• Are we building the right
thing?
• Unit-Tests
• Code oriented
• How?
• Are we building it right?
Picture: RSpec Book
Behavior Specifications are
Examples
• Demonstrating each important aspect
of a system
– Standard cases
– Edge cases
– Critical areas
• The main goal is not a full regression
– However the artifacts of automated examples
can be reused for regression testing
Agile Testing Quadrants
• Agile Testing is more than QA
– Not only detect bugs
– Improve quality by preventing bugs …
Testing Pyramid
• Automation allows more resources for
„valuable“ testing activities
Test
Automation
Pyramid
by
Mike
Cohn
Accessing the App through the UI
• Full end-to-end test
• Driving the UI adds a lot
of accidental complexity
and noise
– Structure of resulting UI is not
clear from the beginning
– Widget selection (CSS-
Selectors, byId …)
– It is hard to drive functionality
Accessing the App just below the UI
• Establish an Architecture
where you can access the
Application just below the UI
– Design for Testability
– PassiveView, ViewModel,
Controller
• Provide an abstraction and a
programmatic API that allows
driving functionality
• The last step has to be
tested by QA
– manually or scripted
Accessing the App through
Application Services
• Core business functionality
often resides in
encapsulated modules
• Drive functionality from the
interface of a module
– Gap between scenario and
implementation grows
– Reliability of a passing scenario
diminishes
• Good example: „Classic“
SOA
Accessing the Domain
• Core business functionality
often resides in a domain
model
• It is possible to bind a
scenario directly to the
domain
– Gap between scenario and
implementation is big
– Danger of leaking too many details
into the scenarios („programming in
plain-text“)
– Usually better suited for unit-tests
It is a trade-off
outside-in,
efficiency, speed
end-to-end
integration
vs.
Stubbing
• Stubbing helps to isolate the feature
– Better for driving the development
– Worse for testing the application
History of BDD
• 2001: Dan North
invented the term
• JBehave (Java)
• RSpec (Ruby)
• Cucumber (Ruby)
„where the hype is today…“
„TDD is not
about
Testing“
„BDD is a
Development
Methodology“
Code-Focused,
Unit-Behavior
Feature-Focused,
System-Behavior
Similar tools in the .NET space
Plain-Text specifications:
• Cucumber via IronRuby
www.cukes.info
• Cuke4Nuke
http://github.com/richardlawrence/Cuke4Nu
ke/
• NBehave
http://nbehave.org/
• Fit/Fitnesse
http://nbehave.org/
• StorEvil
http://wiki.github.com/davidmfoley/storevil/
• StoryQ
http://storyq.codeplex.com/
• Specter
http://specter.sourceforge.net/
• Aubergine
github.com/ToJans/Aubergine
Context/Specification Tools:
• MSpec
http://github.com/machine/machine.specificat
ions
• BDD extension for xUnit
http://code.google.com/p/xunitbddextensions/
• Nspec
http://nspec.tigris.org/
• SpecUnit.Net
http://code.google.com/p/specunit-net/
TechTalk Schweiz sucht Mitarbeiter!
TechTalk ist eine Entwicklungsfirma mit ca. 60 Mitarbeiter in
Wien und Budapest und Zürich. Wir fokussieren auf die .NET
Plattform und auf Scrum.
Wir suchen erfahrene Entwickler für den Aufbau des Standorts
Schweiz:
• Mehrjährige Erfahrung in diversen Projekten, idealerweise in
unterschiedlichen Branchen
• Grosse Flexibilität, Eigeninitiative und Selbstmotivation
• Erfahrung und Bereitschaft für On-Site Einsätze bei Kunden
Wir bieten:
• Aufbau eines jungen Unternehmens in einem kleinem Team
• Möglichkeit eines Aufenthaltes in Wien / Budapest
• Weiterbildung und Verwirklichung eigener Ideen
jobs@techtalk.ch