Co-presentation with Sebastian Bergmann, maintainer of PHPUnit, at SymfonyLive Cologne 2017 (English from slide 3 onward). The business value of testing; despite taking longer in development, projects built using Test-Driven-Development methodologies deliver value sooner, longer, and allow for predictable upgrade and maintenance over their life cycles.
8. Introduction
Why testing? What’s the problem?
Benefits of testing.
Addressing roadblocks and
objections to testing.
Result!
Outline
9. Why testing?
“The software team not only has to ensure that it makes a
positive contribution to the business goals; it must also ensure
that it makes as few negative contributions … as possible.” -
Andresen.
10. Benefits of testing
(business cases)
“Testing solves many problems, the least of which is being
sure the code does what it is supposed to do.”
11. Benefits of testing
(business cases)
“Testing solves many problems, the least of which is being
sure the code does what it is supposed to do.”
12. The Phoenix Project: A Novel About
IT, DevOps, and Helping Your
Business Win
Gene Kim, Kevin Behr, George
Spafford
https://en.wikipedia.org/wiki/
The_Phoenix_Project_(novel)
13. The Four Types of Work
1. Business project
2. IT (Infrastructure/Internal) project
3. Changes (Operational/Maintenance)
4. Unplanned work
14. TDD & the Four Types of Work
TDD helps focus on delivering
features/value through business and
IT projects.
TDD makes changes (Operational/
Maintenance) faster, more secure
TDD reduces unplanned work
24. Pro
1. 18% more functional tests passed
2. More than 2X increase in code quality,
tests served as “auto documentation”
3. more tests == more productivity
more productivity == better quality
4. 20.9% decrease in defects,
decrease in defects found by customers
5. 50% reduction in defect rate,
the test suite “will improve quality over
lifetime of the software system”, “quality
contract” between team members
6. TDD ROI … Show me the money!
Con
1. 16% more development time
2. 15% more development time
3. -
4. 30% more development time
non-iterative testing (improvement
possible)
5. (“minimal development productivity
impact”)
6. -
Summary
28. “In most cases, a client will not
state how long a comparable
previous system functioned …
Request this information and use it
in relation to test-driven
development.” - Andresen.
Photo by CEphoto, Uwe Aranas
33. Delivering the project
is only the beginning
of delivering value.
“Many software teams present quality assurance as a
separate item in their offer … This gives clients the impression
that it is an element that can be eliminated.” - Andresen.
36. Objections &
Questions
1. What can developers get out
testing?
2. How does testing save time and
frustration?
3. But I’m writing the software twice!
That’s twice as much work!
4. What’s the most important tip you
can give about testing?
37. Objections &
Questions
1. What can developers get out
testing?
2. How does testing save time and
frustration?
3. But I’m writing the software twice!
That’s twice as much work!
4. What’s the most important tip you
can give about testing?
41. “Die Hauptaufgabe eines Entwicklers
ist nicht das Schreiben von Code,
sondern das Verstehen eines
Problems. Das Formulieren von Tests,
also der Zielvorgaben, hilft, ein
Problem Schritt für Schritt zu
durchdringen. Die Tests treiben die
Entwicklung also nicht als
Selbstzweck, sondern tun dies, indem
sie die notwendigen Denkprozesse
anstoßen.”
https://thephp.cc/neuigkeiten/2017/02/testen-haelt-mich-von-der-arbeit-ab
44. class AuctionTest extends PHPUnitFrameworkTestCase
{
private $auction;
protected function setUp()
{
$this->auction = new Auction(
new User(
new Name('Tess Tester'),
new Email('tester@example.com')
),
new Description('...'),
new DateTimeImmutable('2017-04-07'),
new DateTimeImmutable('2017-04-15'),
EUR::fromCents(100)
);
}
// ...
}
45. class AuctionTest extends PHPUnitFrameworkTestCase
{
// ...
public function testUserCannotBidOnOwnAuction()
{
$this->expectException(
CannotBidOnOwnAuctionException::class
);
$this->auction->bid(
new Bid(
new DateTimeImmutable(‘2017-04-08'),
$this->auction->getUser(),
EUR::fromCents(100)
)
);
}
}
46. $ phpunit --testdox AuctionTest
PHPUnit 6.0.13 by Sebastian Bergmann and contributors.
Runtime: PHP 7.1.2 with Xdebug 2.5.1
Configuration: /home/sb/example/phpunit.xml
Auction
[x] Has description
[x] Has start date
[x] Has end date
[x] Has initial price
[x] User can bid on auction created by another user
[x] User cannot bid on own auction
[x] User cannot bid on auction that has not yet started
[x] User cannot bid on auction that has already ended