open source bridge testing antipatterns presentation

43
Testing Antipatterns Matt Robinson Puppet Labs

Upload: mmrobins

Post on 18-Nov-2014

811 views

Category:

Technology


2 download

DESCRIPTION

These are the slides for the presentation I gave on antipatterns used in testing. This was at Open Source Bridge in June of 2011.

TRANSCRIPT

Page 1: Open source bridge testing antipatterns presentation

Testing Antipatterns

Matt RobinsonPuppet Labs

Page 2: Open source bridge testing antipatterns presentation

Anti - What?

Page 3: Open source bridge testing antipatterns presentation

Antipattern (Dark

Pattern):A pattern that is commonly used but is ineffective and/or counterproductive

Page 4: Open source bridge testing antipatterns presentation
Page 5: Open source bridge testing antipatterns presentation

Who has an extensive test

suite?

Page 6: Open source bridge testing antipatterns presentation

Who feels like they should test more?

Page 7: Open source bridge testing antipatterns presentation

Who dislikes, even dreads, writing

tests?

Page 8: Open source bridge testing antipatterns presentation

Testing Can Be Fun

TextTextTextText

http://xkcd.com/583/

Page 9: Open source bridge testing antipatterns presentation

For example:

Page 10: Open source bridge testing antipatterns presentation

Red Green TDD Addiction

Page 11: Open source bridge testing antipatterns presentation

Testing Framework Games

(although these can be a distraction)

Page 12: Open source bridge testing antipatterns presentation

Not looking like an idiot - that’s fun

right?

Page 13: Open source bridge testing antipatterns presentation

Why Automated Testing?

•Prevents regressions

•Improves confidence

•Documents requirements

•Catches errors before codes ships

•You fill in the blank _________

Page 14: Open source bridge testing antipatterns presentation

Overheard Reasons Not to

Test•Don’t trust the tests

•Who tests the tests? Quis custodiet ipsos custodes?

•Makes refactoring harder

•Not enough return on investment (ROI)

•Too hard and/or time consuming

Page 15: Open source bridge testing antipatterns presentation

Antipatterns that have bitten me the

most

Page 16: Open source bridge testing antipatterns presentation

Not Running Tests Often Enough

Page 17: Open source bridge testing antipatterns presentation

If it’s Hard and Important Do it

More Often

Page 18: Open source bridge testing antipatterns presentation

testing, deploying, releasing, exercising,

meditating, writing, public speaking

Page 19: Open source bridge testing antipatterns presentation

How Often?• Before deployment or release

• After every commit: CI (Continuous Integration) - Jenkins, Cruise Control, BuildBot, Cerebrus, CI Joe

• Before every commit (or push): discipline, git hooks

• Every save: autotest, watchr

Page 20: Open source bridge testing antipatterns presentation

Not Fixing Broken Tests Before

Committing New Code

Page 21: Open source bridge testing antipatterns presentation

The Slowpoke

Page 22: Open source bridge testing antipatterns presentation

How Slow Is Too Slow?

Page 23: Open source bridge testing antipatterns presentation

Unit Test Suite Took 8 Hours to Run - On One

Project

Page 24: Open source bridge testing antipatterns presentation

Single Test Took 2 Minutes to Start

Page 25: Open source bridge testing antipatterns presentation

So slow that rewriting it in PHP

would make it faster

Page 26: Open source bridge testing antipatterns presentation

How to Get Faster•Make your implementation code faster

•Run your tests in parallel

•Optimize your tests (new framework, trick garbage collector, rewrite culprits)

•Mark some tests as slow and only run them occasionally

Page 27: Open source bridge testing antipatterns presentation

The Mockery

Page 28: Open source bridge testing antipatterns presentation

Why mock when the real things will do?

Page 29: Open source bridge testing antipatterns presentation

Testing at the Wrong Level

Page 30: Open source bridge testing antipatterns presentation

unit, smoke, functional, integration, acceptance

Page 31: Open source bridge testing antipatterns presentation

Success Against All Odds

(test never fails)

Page 32: Open source bridge testing antipatterns presentation
Page 33: Open source bridge testing antipatterns presentation

Testing Implementation

Instead of Behavior

Page 34: Open source bridge testing antipatterns presentation

Testing Implementation

Page 35: Open source bridge testing antipatterns presentation

Testing Behavior

Page 36: Open source bridge testing antipatterns presentation

Order Dependent Failures

Page 37: Open source bridge testing antipatterns presentation

You’ve got too much global state

Page 38: Open source bridge testing antipatterns presentation

Excessive Setup

Page 39: Open source bridge testing antipatterns presentation

What are we testing again?

Page 40: Open source bridge testing antipatterns presentation

•The Dodger - Never tests desired behavior

•The Stranger - Misplaced tests

•Local Hero - Worked on my dev box

•Generous Leftovers - Fills your hard drive

•The Giant - You may have a God object

•The Loudmouth - Spams your test logs

Other Antipatterns

Page 41: Open source bridge testing antipatterns presentation

Summary

Page 42: Open source bridge testing antipatterns presentation

Avoid Antipatterns and Testing Can Be

Fun

Page 43: Open source bridge testing antipatterns presentation

Links

http://blog.james-carr.org/2006/11/03/tdd-anti-patterns/

http://jasonrudolph.com/blog/testing-anti-patterns-how-to-fail-with-100-test-coverage/

http://blog.rubybestpractices.com/posts/gregory/034-issue-5-testing-antipatterns.html

http://c2.com/cgi/wiki?AntiPatternsCatalog

http://martinfowler.com/articles/mocksArentStubs.html