TDD refresher
Upcoming SlideShare
Loading in...5
×
 

TDD refresher

on

  • 697 views

TDD talk for new grad

TDD talk for new grad

Statistics

Views

Total Views
697
Views on SlideShare
697
Embed Views
0

Actions

Likes
2
Downloads
13
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

TDD refresher TDD refresher Presentation Transcript

  • Test-drivendevelopment Kerry Buckley 2 November 2012
  • TDD refresher
  • Towards TDD 0. manual testing WriteDesign Test Release code View slide
  • Towards TDD 1. automated testing Write WriteDesign Test Release code tests View slide
  • Towards TDD 2. test-first development Write WriteDesign Test Release tests code
  • Towards TDD 3. test-driven developmentDesign Write Run Write test test code Release Run Refactor tests
  • Towards TDD3. test-driven development Red Green Refactor
  • Beyond TDD? 4. behaviour-driven development ExecutableCustomer Release examples Red Green TDD Refactor
  • Types of test
  • Acceptance tests Test System
  • Integrated tests Test Test
  • Unit tests Test TestMock Mock Mock
  • Anatomy of a test # Given some test accounts➊ Setup account_1 = Account.new(100) account_2 = Account.new(50) # When I transfer money➋ Act transfer(20, from: account_1, to: account_2) # Then the balances should be updated➌ Assert account_1.balance.should eq(80) account_2.balance.should eq(70)
  • A good test…
  • A good test…• Expresses the programmer’s intent
  • A good test…• Expresses the programmer’s intent• Gives confidence that the code works
  • A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing
  • A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear failure message
  • A good test…• Expresses the programmer’s intent• Gives confidence that the code works• Only tests one thing• Gives clear failure message• Is independent of other tests
  • A good test suite…
  • A good test suite…• Gives confidence that the system works
  • A good test suite…• Gives confidence that the system works• Runs quickly
  • A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained
  • A good test suite…• Gives confidence that the system works• Runs quickly• Is well-maintained• Isolates each area under test
  • Benefits of TDD
  • Benefits of TDD• Less manual testing required
  • Benefits of TDD• Less manual testing required• Faster feedback
  • Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code
  • Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging
  • Benefits of TDD• Less manual testing required• Faster feedback• Make it safe to change code• Reduced rework and debugging• Improved design
  • How do I start?
  • How do I start?• Greenfield project? JFDI! Otherwise…
  • How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first
  • How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features
  • How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur
  • How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur• Use TDD for new features
  • How do I start?• Greenfield project? JFDI! Otherwise…• Automate highest value tests first • Important features • Where the most bugs occur• Use TDD for new features• Add tests for bugs when they’re found
  • Further reading