28
Influencing Software Developers Towards More Testable Code Base & More Tests Miško Hevery

Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Influencing Software Developers Towards

More Testable Code Base & More Tests

Miško Hevery

Page 2: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Question

• Which of you are trying to change your organization?

• Where is your organization with respect to unit-testing?

• Do you TDD?

• How do you get started?

2

Page 3: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Development Model

Develop

Test

Check-In

automate

3

Page 4: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Common Misconception

Valid Excuse

No Tests

Excuses

Legacy code-base

It’s sl

ower

It doesn’t catch bugs It’s boring

Testing is for QA

I write UI

Too many interfaces

“Dirties Design”

Don’tknowhow

Hard to change

4

Page 5: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Interview Question

How do you write HARD TO TEST

code?

5

Page 6: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

TestEngineers

SoftwareEngineers

Automated Tests

QA

Development Model

Develop

Manual Tests

Testing magicTools

Testing magicDesign

6

Page 7: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Enforcement

VisibilityTools

Education

Dev Model Revisited

Develop

Test

Check-In

Review

Testing on the ToiletTech Talks / Blogs1 on 1 TrainingMercenariesImmersion

ToolsAnalysisReports

Games DashboardsScoreboards

Trend Graphs

RoboCopTestabilityCoverage

CI-build

7

Page 8: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: Test Mercenaries

• Internal consulting group specializing in testability refactorings and influencing developers

• 2-3 mercenaries join the group for 3-6 months

8

Page 9: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: Tech Talks

• Weekly series• Focus on common

mistakes which make code hard to test–new, global-state,

singletons, LoD• Many available on You

Tube

9

Page 10: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: Reviewers Guide

• We try to stick it on everyones monitor

• Set of red-flags to look for• URL pointing to an explanation

of the red-flag• The reviewer can point the

author to the explanation page

10

Page 11: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: Mission Impossible

• Mercenaries in reverse• Total Immersion• work with team for a

month which “gets it”• Very good feedback

11

Page 12: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: TotT• Weekly publications• Testing Tips (not

concepts)• Captive audience• Very successful

12

Page 13: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: Blog

• Venue for larger concepts which do not fit to TotT.

• Shared with outside world

13

Page 14: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Education: TDD University

• Build small project from scratch–Learn how the code should be like

• Rewrite existing piece of code–To see how it is different

• Refactor existing code–To learn how to get from here to there

14

Page 15: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Tools: Coverage• Simple but effective• Just having it

installed makes people thing about improving coverage

• Squeaky wheel gets the grease

15

Page 16: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Tools: Test Farms

• Farms• Ability to run

massive test suites in parallel–Selenium–unit-test–browser matrix

16

Page 17: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Tools: Testability Report

• Code coverage for testability

• Get high level view about how testable the code is

17

Page 18: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Tools: Testability Advice

• Personal testability advisor

• Plans to integrate into IDE

• Virtual pairing buddy

18

Page 19: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Visibility: Games

• Make it into a game

19

Page 20: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Visibility: Bubbles

• See quality of check-ins over time• Time, Tests, User, Size

20

Page 21: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Visibility: Test Pareto

• Test ratios per developer• Impact per developer

21

Page 22: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Visibility: Test Trend

• Test focus over time

22

Page 23: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Visibility: Certification

• Well defined standards–To be at N level you need to do

X, Y, and Z.• TC level prestige

23

Page 24: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Enforcement: Tough Love

• Remove manual testing resources• Provide knowledge and support

24

Page 25: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Enforcement: RoboCop

• Coverage can not get worse with any one CL

• Testability can not get worse with any one CL

• Plans for arbitrary rule enforcement

25

Page 26: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Progress

• Too many tests too run• CI standard• Everyone agrees tests are good idea• TC Level• Dependency Injection - GUICE• Ratio System vs Unit is improving

26

Page 27: Influencing Software Developers Towards More Testable Code ...misko.hevery.com/wp-content/uploads/2008/07/GeeCON.pdf · Tools: Testability Report • Code coverage for testability

Q&A?27