SlideShare a Scribd company logo
TDD is Dead, Long Live TDD
Works for
 Trainer
 Software Engineer
 @__jacker__
[test]
[test] noun
A procedure intended to establish the
quality, performance, or reliability of
something, especially before it is taken
into widespread use.
[test] verb
To do something in order to discover if
something is safe, works correctly, etc.,
or if something is present
[test] verb synonyms
Prove, Assess, Examine
Write code – test it works
class Calculator
{
public function sum($a, $b)
{
return $a + $b;
}
}
$result = $calculator->sum(2, 3);
$this->assertEquals($result, 5)
Test Driven Development
Kent Beck
“Rediscovered” TDD in 1994
“TDD By Example” –
Published 2002
Digital Computer
Programming
- Daniel Delbert McCracken 1957
The hand calculations can be done at any
point during programming. […] In these
cases it is highly desirable that the
"customer" prepare the check case,
largely because logical errors and
misunderstandings between the
programmer and customer may be
pointed out by such procedure.
PASS
REFACTOR
FAIL
RED / GREEN / REFACTOR
Kent Beck - 2002
Test-Driven Development is a
way of managing fear during
programming
Test Driven Development
Driven ??
What is software driven by?
Fun
Profit
Business Requirements
What is software driven by?
Requirements Examples
Test Driven Development
By
Examples
Specification By Example
Specification by Example
– Martin Fowler 2004
Tests based on shared examples fit best in the
category of tests designed to support a team while
delivering software from a business perspective -
ensuring that the right product is built
[specification] noun
a detailed description or assessment
of requirements, dimensions,
materials, etc., as of a proposed
building, machine, bridge, etc.
[specification] in Technology
(spec) A document describing how
some system should work.
$result = $calculator->sum(2, 3);
$this->assertEquals($result, 5)
Test?
Spec?
Did you write it
before the
code?
It’s a Test
It’s a
Specification
YesNo
Changing the way of thinking about the same
problem by changing the language used to
describe it
To reframe, then, means to change the
conceptual and emotional setting or viewpoint
in relation to which a situation is experienced
and to place it in another frame which fits the
'facts' of the same concrete situation equally
well or even better, and thereby changing its
entire meaning.
1974, Watzlawick, Weakland and Fisch
RSpec – 2005 –
Making TDD Productive and
Started as an experiment by Steven Baker
Fun
Don’t rush ahead with
more code.
Instead, add another
example and let it guide you
to what you have to do next.
… using tests to drive the
features and the object-
oriented structure of the
code, and using Mock
Objects to discover and
then describe
relationships between
objects
2007 - PHPSpec 1.0 - Padraic Brady & Travis Swicegood
A Port of RSpec 4
SpecBDD
2010 - PHPSpec 2.0 – Complete rewrite by –
Marcello Duarte & Konstantin Kudryashov
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
• public function testListContainsKeyword()
{
$basket = new Basket();
$basket->add('apple');
$this->assertTrue($basket->has('apple'));
}
What we’re going to test
Make an assertion about what it should return
• public function it_returns_true_if_it_has_an_apple()
{
$this->add('apple');
$this->has('apple’)->shouldReturn(true);
}
Specifying desired behavior
Set up an expectation of the behavior
Classic TDD Kata (exercise)
The String Calculator
 Returns 0 for an empty string
 Returns the “bare” number given one number
 Returns the sum of numbers separated by space
StringCalculator
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
A “Real Life” Example
Acceptance Criteria??
I want something that will
- allow searching Wikipedia for a
keyword,
- keep track of past searches
- highlights results that contain previous
search terms.
- (but not my current one)
Hmm… guess I’ll need to
- Store searched in database?
session?
- Make remote calls to wikipedia
- What’s wikipedia’s API like?
- What color will the highlight be?
Focus on one Problem
- Ignore the infrastructure
- Ignore the framework
- What’s left?
Infrastructure Boundary
Your Domain /
Business Logic
Remote
API
Your Domain /
Business Logic
Wikipedia
Search
Client
+ searchFor(term)
SearchHistory
+ track(term)
+ findAll() : array
SearchController
+ lookup(term)
HighlightingSearch
+ search(term)
SearchResult
+ highlight()
+ matches(history)
0..*
Collaborators
Client
+ searchFor(term)
SearchHistory
+ track(term)
+ findAll() : array
HighlightingSearch
+ search(term)
SearchResult
+ highlight()
+ matches(history)
Doubles / Mocks
Client
+ searchFor(term)
SearchHistory
+ track(term)
+ findAll() : array
HighlightingSearch
+ search(term)
SearchResult
+ highlight()
+ matches(history)
0..*
class HighlightingSearchSpec extends ObjectBehavior
{
function let(SearchHistory $searchHistory, Client $client)
{
$this->beConstructedWith($searchHistory, $client);
}
}
class HighlightingSearchSpec extends ObjectBehavior
{
function let(SearchHistory $searchHistory, Client $client)
{
$this->beConstructedWith($searchHistory, $client);
}
}
double double
class HighlightingSearch
{
private $searchHistory;
private $client;
public function __construct(
SearchHistory $searchHistory,
Client $client
) {
$this->searchHistory = $searchHistory;
$this->client = $client;
}
}
class HighlightingSearch
{
private $searchHistory;
private $client;
public function __construct(
SearchHistory $searchHistory,
Client $client
) {
$this->searchHistory = $searchHistory;
$this->client = $client;
}
}
dependency dependency
namespace AcmeWiki;
interface SearchHistory
{
public function add(string $term);
public function findAll() : array;
}
namespace AcmeWiki;
interface Client
{
public function searchFor(string $term) : array;
}
namespace AcmeWiki;
interface SearchResult
{
public function highlight();
public function matches(array $historicTerms) : bool;
}
 Keeps track of search history
 Returns a collection of search results
 Highlights results whose titles do match historic terms
 Does not highlight any results if there is no search history
 Does not highlight results whose titles don’t match historic terms
 Ignores the current search term
 Only matches whole words
HighlightingSearch
 Keeps track of search history
 Returns a collection of search results
 Highlights results whose titles do match historic terms
 Does not highlight any results if there is no search history
 Does not highlight results whose titles don’t match historic terms
 Ignores the current search term
 Only matches whole words
HighlightingSearch
delegated to SearchResult
 Keeps track of search history
 Returns a collection of search results
 Highlights results whose titles do match historic terms
 Does not highlight any results if there is no search history
 Does not highlight results whose title don’t match historic terms
 Ignores the current search term
 Only matches whole words
HighlightingSearch
delegated to SearchResult
 Keeps track of search history
 Returns a collection of search results
 Highlights results whose titles do match historic terms
 Does not highlight any results if there is no search history
 Does not highlight results whose title don’t match historic terms
 Ignores the current search term
 Only matches whole words
HighlightingSearch
delegated to SearchResult
Is this a requirement?
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Lets build HighlightingSearch
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Tdd is Dead, Long Live TDD
Thank You!

More Related Content

PDF
Architecting your Content for the Unknown Consumer
PDF
Introducing Eager Design
PDF
TDD with PhpSpec - Lone Star PHP 2016
PPTX
Haystack 2018 - Algorithmic Extraction of Keywords Concepts and Vocabularies
PDF
PDF
Measuring Your Code
PDF
Measuring Your Code 2.0
PPTX
The Key to Keys - Database Design
Architecting your Content for the Unknown Consumer
Introducing Eager Design
TDD with PhpSpec - Lone Star PHP 2016
Haystack 2018 - Algorithmic Extraction of Keywords Concepts and Vocabularies
Measuring Your Code
Measuring Your Code 2.0
The Key to Keys - Database Design

Similar to Tdd is Dead, Long Live TDD (20)

PPTX
RSpec: What, How and Why
PDF
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
PPT
Advanced full text searching techniques using Lucene
PPSX
Test analysis & design good practices@TDT Iasi 17Oct2013
PPT
Linq To The Enterprise
PPTX
Domain Driven Design
ODP
New Ideas for Old Code - Greach
PPT
Linq 1224887336792847 9
PPTX
SQL Saturday 28 - .NET Fundamentals
PDF
Performance Tuning of .NET Application
PPT
Hands on Mahout!
PDF
A Practical Enterprise Feature Store on Delta Lake
PDF
TDD with PhpSpec
PPTX
Techorama 2017 - Testing the unit, and beyond.
PPTX
Data ware house design
PPTX
Data ware house design
PDF
beyond-regular-regular-expressions-v20.pdf
PPTX
BDD in my team: how we do it
ODP
HTML Templates Using Clear Silver
PDF
Get your organization’s feet wet with Semantic Web Technologies
RSpec: What, How and Why
Apache Spark Structured Streaming for Machine Learning - StrataConf 2016
Advanced full text searching techniques using Lucene
Test analysis & design good practices@TDT Iasi 17Oct2013
Linq To The Enterprise
Domain Driven Design
New Ideas for Old Code - Greach
Linq 1224887336792847 9
SQL Saturday 28 - .NET Fundamentals
Performance Tuning of .NET Application
Hands on Mahout!
A Practical Enterprise Feature Store on Delta Lake
TDD with PhpSpec
Techorama 2017 - Testing the unit, and beyond.
Data ware house design
Data ware house design
beyond-regular-regular-expressions-v20.pdf
BDD in my team: how we do it
HTML Templates Using Clear Silver
Get your organization’s feet wet with Semantic Web Technologies
Ad

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPT
Introduction Database Management System for Course Database
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
L1 - Introduction to python Backend.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
ai tools demonstartion for schools and inter college
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Nekopoi APK 2025 free lastest update
How to Migrate SBCGlobal Email to Yahoo Easily
Understanding Forklifts - TECH EHS Solution
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Introduction Database Management System for Course Database
Odoo POS Development Services by CandidRoot Solutions
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Softaken Excel to vCard Converter Software.pdf
L1 - Introduction to python Backend.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
CHAPTER 2 - PM Management and IT Context
ai tools demonstartion for schools and inter college
How to Choose the Right IT Partner for Your Business in Malaysia
Odoo Companies in India – Driving Business Transformation.pdf
ISO 45001 Occupational Health and Safety Management System
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Nekopoi APK 2025 free lastest update
Ad

Tdd is Dead, Long Live TDD

Editor's Notes

  • #8: Old school - write code first then test it works correctly , maybe with browser
  • #12: Idea of writing test first goes back a long way, but beck *formamalized* it R G R
  • #13: – First textbook on computer programming
  • #15: Many themes developed in this book including the ideas developed later by Steve Freeman and Nat Pryce such as “writing tests before code to grow software organically” Growing object oriented software guided by tests
  • #16: Kent beck – tests in programming are like the ratchet which help you slow down and prevent you from sliding backwards whilst pulling up a heavy load which is likely to slip
  • #23: The examples trigger abstractions in the design team while keeping the abstractions grounded. You do need more - things like regular conversation, techniques like Domain Driven Design, indeed even doses of Design by Contract.
  • #24: Specification By Example only works in the context of a working relationship where both sides are collaborating and not fighting.
  • #32: Rspec 2005 changed the language and consequently the frame of reference.
  • #33: Rspec book came out in 2010