testing: the more you do it, the more you'll like it

53
Testen: Je mehr Du es tust, desto mehr wirst Du es lieben “I can’t believe we’re still talking about this!”

Upload: jeffrey-mcguire

Post on 13-Apr-2017

10 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Testing: the more you do it, the more you'll like it

Testen: Je mehr Du es tust,desto mehr wirst Du es lieben

“I can’t believe we’re still talking about this!”

Page 2: Testing: the more you do it, the more you'll like it

Testen: Je mehr Du es liebst,desto mehr wirst Du es tun

“I can’t believe we’re still talking about this!”

Page 3: Testing: the more you do it, the more you'll like it
Page 4: Testing: the more you do it, the more you'll like it

Sebastian Bergmann

@s_bergmann

[email protected]

27 years programming experience

19 years PHP experience

Co-Founder of thePHP.cc

Page 5: Testing: the more you do it, the more you'll like it

Jeffrey A. "jam" McGuire

Evangelist, DevRel Acquia

dev.acquia.com/podcast

@horncologne

[email protected]

[email protected]

Page 6: Testing: the more you do it, the more you'll like it

Acquia Podcast: dev.acquia.com/podcast

Page 7: Testing: the more you do it, the more you'll like it
Page 8: Testing: the more you do it, the more you'll like it

Introduction

Why testing? What’s the problem?

Benefits of testing.

Addressing roadblocks and objections to testing.

Result!

Outline

Page 9: Testing: the more you do it, the more you'll like it

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.

Page 10: Testing: the more you do it, the more you'll like it

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.”

Page 11: Testing: the more you do it, the more you'll like it

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.”

Page 12: Testing: the more you do it, the more you'll like it

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)

Page 13: Testing: the more you do it, the more you'll like it

The Four Types of Work

1. Business project

2. IT (Infrastructure/Internal) project

3. Changes (Operational/Maintenance)

4. Unplanned work

Page 14: Testing: the more you do it, the more you'll like it

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

Page 15: Testing: the more you do it, the more you'll like it

Really?

Yes, really.

Page 16: Testing: the more you do it, the more you'll like it

Time out!State-of-play?

Do you even test?

Page 17: Testing: the more you do it, the more you'll like it

I find your lack of tests disturbing.

Page 18: Testing: the more you do it, the more you'll like it

Really?

Yes, really.

Page 19: Testing: the more you do it, the more you'll like it

http://dl.acm.org/citation.cfm?id=952753 SAC '03 Proceedings of the 2003 ACM symposium on Applied computing Pages 1135-1139 ACM New York, NY, USA ©2003 ISBN:1-58113-624-2

1

Page 20: Testing: the more you do it, the more you'll like it

http://dl.acm.org/citation.cfm?id=1159787 ISESE '06 Proceedings of the 2006 ACM/IEEE international symposium on Empirical software engineering, Pages 356-363 ACM New York, NY, USA ©2006 ISBN:1-59593-218-6

2

Page 21: Testing: the more you do it, the more you'll like it

http://dl.acm.org/citation.cfm?id=1070834 IEEE Transactions on Software Engineering Volume 31 Issue 3, March 2005 Page 226-237

3

Page 22: Testing: the more you do it, the more you'll like it

http://dl.acm.org/citation.cfm?id=1802420 ISSRE'09 Proceedings of the 20th IEEE international conference on software reliability engineering, Pages 81-89 IEEE Press Piscataway, NJ, USA ©2009 ISBN: 978-1-4244-5375-7

4

Page 23: Testing: the more you do it, the more you'll like it

http://dl.acm.org/citation.cfm?id=776892 ICSE '03 Proceedings of the 25th International Conference on Software Engineering, Pages 564-569, IEEE Computer Society Washington, DC, USA ©2003 ISBN:0-7695-1877-X

5

Page 24: Testing: the more you do it, the more you'll like it

Pro1. 18% more functional tests passed2. More than 2X increase in code quality,

tests served as “auto documentation”3. more tests == more productivity

more productivity == better quality4. 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!

Con1. 16% more development time2. 15% more development time

3. -

4. 30% more development time non-iterative testing (improvement possible)

5. (“minimal development productivity impact”)

6. -

Summary

Page 25: Testing: the more you do it, the more you'll like it

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.7.4232 About the Return on Investment of Test-Driven Development (2003) Matthias M. Müller , Frank Padberg International Workshop on Economics-Driven Software Engineering Research EDSER-5

6

Page 26: Testing: the more you do it, the more you'll like it

Conventional

TDD

Development Quality Assurance

Development

InvestmentLife Cycle Benefit

Net Return

Müller / Radberg - TDD Benefit/Cost Ratio Calculation

Page 27: Testing: the more you do it, the more you'll like it

Photo by CEphoto, Uwe Aranas

Page 28: Testing: the more you do it, the more you'll like it

“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

Page 29: Testing: the more you do it, the more you'll like it
Page 30: Testing: the more you do it, the more you'll like it

Developers!

This book is your friend!

https://leanpub.com/SellingTestDrivenProjects

Page 31: Testing: the more you do it, the more you'll like it

Boehm - Relative cost of a bug-fix

0

40

80

120

160 150X

50X

20X10X5X1X

Requirements Design Code Developer Tests

Acceptance Tests

Operations

Page 32: Testing: the more you do it, the more you'll like it

Developers!

This book is your friend!

https://leanpub.com/SellingTestDrivenProjects

Page 33: Testing: the more you do it, the more you'll like it

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.

Page 34: Testing: the more you do it, the more you'll like it

Sounds convincing … Devs?

Page 35: Testing: the more you do it, the more you'll like it

Roadblocks,Questions, Objections

Getting to testing

Page 36: Testing: the more you do it, the more you'll like it

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?

Page 37: Testing: the more you do it, the more you'll like it

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?

Page 38: Testing: the more you do it, the more you'll like it

Specification

Page 39: Testing: the more you do it, the more you'll like it

Documentation

Page 40: Testing: the more you do it, the more you'll like it

Verification

Page 41: Testing: the more you do it, the more you'll like it

“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

Page 42: Testing: the more you do it, the more you'll like it

Carola Lilienthalllsa.de

Page 43: Testing: the more you do it, the more you'll like it

Carola Lilienthal

Page 44: Testing: the more you do it, the more you'll like it

class AuctionTest extends PHPUnit\Framework\TestCase{ private $auction;

protected function setUp() { $this->auction = new Auction( new User( new Name('Tess Tester'), new Email('[email protected]') ), new Description('...'), new DateTimeImmutable('2017-04-07'), new DateTimeImmutable('2017-04-15'), EUR::fromCents(100) ); }

// ...}

Page 45: Testing: the more you do it, the more you'll like it

class AuctionTest extends PHPUnit\Framework\TestCase{ // ...

public function testUserCannotBidOnOwnAuction() { $this->expectException( CannotBidOnOwnAuctionException::class );

$this->auction->bid( new Bid( new DateTimeImmutable(‘2017-04-08'), $this->auction->getUser(), EUR::fromCents(100) ) ); }}

Page 46: Testing: the more you do it, the more you'll like it

$ phpunit --testdox AuctionTestPHPUnit 6.0.13 by Sebastian Bergmann and contributors.

Runtime: PHP 7.1.2 with Xdebug 2.5.1Configuration: /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

Page 47: Testing: the more you do it, the more you'll like it

Result! Result!

Page 48: Testing: the more you do it, the more you'll like it

Introduction

Why testing? What’s the problem?

Benefits of testing.

Addressing roadblocks and objections to testing.

Result!

Recap

Page 49: Testing: the more you do it, the more you'll like it

Photo Creditshttps://creativecommons.org/licenses/by-nc-sa/2.0/:

Sebastian Bergmann https://www.flickr.com/photos/stuartherbert/6231499431

Locomotive spec https://www.flickr.com/photos/12567713@N00/281324130

Steam engine https://www.flickr.com/photos/lofink/445470024

Train maintenance https://www.flickr.com/photos/kheelcenter/5279863818/

Motorcycle rider https://www.flickr.com/photos/conner395/8339912312

https://creativecommons.org/licenses/by-nc-sa/2.0/:

Köln/Bonn Flughafen night https://www.flickr.com/photos/top10-flickr/8676295874/

Köln/Bonn Flughafen day https://www.flickr.com/photos/dirkvorderstrasse/10583451894/

Flughafen Köln/Bonn ceiling https://www.flickr.com/photos/fridgemonkey/4262843982/

—————

Köln Musical Dome photo by CEphoto, Uwe Aranas https://commons.wikimedia.org/wiki/File:Cologne_Germany_Musical-Dome-01.jpg

Page 50: Testing: the more you do it, the more you'll like it

Developers!

This book is your friend!

https://leanpub.com/SellingTestDrivenProjects

Page 51: Testing: the more you do it, the more you'll like it

Carola Lilienthalllsa.de

Page 52: Testing: the more you do it, the more you'll like it

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.7.4232 About the Return on Investment of Test-Driven Development (2003) Matthias M. Müller , Frank Padberg International Workshop on Economics-Driven Software Engineering Research EDSER-5

6

Page 53: Testing: the more you do it, the more you'll like it

Thank you!Questions?Sebastian Bergmann @[email protected]

Jeffrey A. "jam" McGuire @[email protected]@gmail.com