Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
A Pragmatic Introduction
t o U n i t Te s t i n g
Josh Gillespie
Polaris Solutions
St. Louis Days of .NET
Platinum
Sponsors

Gold Sponsors

Silver
Sponsors
Agenda
• Reasoning
• Hello World
• Digging Deeper
Reasoning
Why do we test stuff?
What is Unit Testing?
“In computer programming, unit testing is a method by which
individual units of source code are test...
Why Unit test?
• Better Design
• Easier change
• Living documentation
• Reduces cost
Basic anatomy
Demo
Let’s write some tests!
Digging Deeper
We know what a unit test looks like… Now what?
What do we test?
and what DON’T we test?
•
•
•
•
•
•
•
•

Where to Start?
Starting with New Code
Starting with Old Code
Code Importance
• Priority = (importance) * (flux)
•
•

Test Coverage
What to Verify?
• Inputs and Outputs
• Direct and Indirect

• Result verification
•
•
•
•

State
Behavior
Delta
Guard
Types of Unit Tests
W r i t i n g B e t t e r Te s t s
Fast
Conditional Test - Bad
Simpler Test(s) - Good
Consistent/Deterministic
Inconsistent Test - Bad
Self Descriptive
Self Descriptive - Good
Atomic
Single Responsibility Principle (SRP)
Isolation
Bad Isolation
Isolation – Production Code
Automation
Portable
Questions?
Thank you!
Josh Gillespie
Josh.Gillespie@PolarisSolutions.com
Image Credits
• http://www.flickr.com/photos/somemixedstuff/240324950
1/

• http://www.flickr.com/photos/threedots/1158050...
A Pragmatic Introduction to Unit Testing
A Pragmatic Introduction to Unit Testing
A Pragmatic Introduction to Unit Testing
Upcoming SlideShare
Loading in …5
×

A Pragmatic Introduction to Unit Testing


We've all heard about unit testing and all been told we should test everything all the time, but where do we start? Is it just for greenfield development or can you apply it to existing code? In this session we'll cut through the hype, discuss the core concepts, and learn how to get started.

  • Be the first to comment

A Pragmatic Introduction to Unit Testing

  1. 1. A Pragmatic Introduction t o U n i t Te s t i n g Josh Gillespie Polaris Solutions St. Louis Days of .NET
  2. 2. Platinum Sponsors Gold Sponsors Silver Sponsors
  3. 3. Agenda • Reasoning • Hello World • Digging Deeper
  4. 4. Reasoning Why do we test stuff?
  5. 5. What is Unit Testing? “In computer programming, unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application” – Wikipedia (emphasis added)
  6. 6. Why Unit test? • Better Design • Easier change • Living documentation • Reduces cost
  7. 7. Basic anatomy
  8. 8. Demo Let’s write some tests!
  9. 9. Digging Deeper We know what a unit test looks like… Now what?
  10. 10. What do we test? and what DON’T we test?
  11. 11. • • • • • •
  12. 12. • • Where to Start?
  13. 13. Starting with New Code
  14. 14. Starting with Old Code
  15. 15. Code Importance • Priority = (importance) * (flux)
  16. 16. • • Test Coverage
  17. 17. What to Verify? • Inputs and Outputs • Direct and Indirect • Result verification • • • • State Behavior Delta Guard
  18. 18. Types of Unit Tests
  19. 19. W r i t i n g B e t t e r Te s t s
  20. 20. Fast
  21. 21. Conditional Test - Bad
  22. 22. Simpler Test(s) - Good
  23. 23. Consistent/Deterministic
  24. 24. Inconsistent Test - Bad
  25. 25. Self Descriptive
  26. 26. Self Descriptive - Good
  27. 27. Atomic
  28. 28. Single Responsibility Principle (SRP)
  29. 29. Isolation
  30. 30. Bad Isolation
  31. 31. Isolation – Production Code
  32. 32. Automation
  33. 33. Portable
  34. 34. Questions?
  35. 35. Thank you! Josh Gillespie Josh.Gillespie@PolarisSolutions.com
  36. 36. Image Credits • http://www.flickr.com/photos/somemixedstuff/240324950 1/ • http://www.flickr.com/photos/threedots/115805043/ • http://www.flickr.com/photos/51029297@N00/52754033 64/ • http://www.flickr.com/photos/hey__paul/7511823644/ • http://www.flickr.com/photos/johne777/9388708662/ • http://www.flickr.com/photos/eleaf/2536358399/ • http://www.flickr.com/photos/jurvetson/6858583426/ • http://www.flickr.com/photos/oskay/472097903/ • http://www.flickr.com/photos/75001512@N00/3241693417 • http://www.flickr.com/photos/dwilliams617/4861890322/ • http://www.flickr.com/photos/futureshape/2494977521/ • http://www.flickr.com/photos/jronaldlee/4478655355/ • http://www.flickr.com/photos/johngreenaway/3356358479/ • http://www.flickr.com/photos/72284410@N08/65220791 51/ • http://www.flickr.com/photos/49319458@N07/4524180396 • http://www.flickr.com/photos/jakecaptive/3205277810/ • http://www.flickr.com/photos/cogdog/5528772562/ • http://www.flickr.com/photos/polarjez/5161505483/ • http://www.flickr.com/photos/jbozanowski/4116825468 • http://www.flickr.com/photos/valeriebb/290711738/ • http://www.flickr.com/photos/carbonnyc/5015794211/ • http://www.flickr.com/photos/olibac/560079597/ • http://hyperboleandahalf.blogspot.com/2010/06/this-iswhy-ill-never-be-adult.html

    Be the first to comment

    Login to see the comments

  • angelabinkowski

    Nov. 19, 2013

We've all heard about unit testing and all been told we should test everything all the time, but where do we start? Is it just for greenfield development or can you apply it to existing code? In this session we'll cut through the hype, discuss the core concepts, and learn how to get started.

Views

Total views

1,314

On Slideshare

0

From embeds

0

Number of embeds

260

Actions

Downloads

0

Shares

0

Comments

0

Likes

1

×