• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Automated Unit Testing for Mere Mortals
 

Automated Unit Testing for Mere Mortals

on

  • 623 views

 

Statistics

Views

Total Views
623
Views on SlideShare
623
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

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
  • Roughly in order of implementation, from least (no) to full Good article in this month’s MSDN Magazine discussing the difference

Automated Unit Testing for Mere Mortals Automated Unit Testing for Mere Mortals Presentation Transcript

  • Automated Unit Testing for Mere Mortals Jess Chadwick Architect / RIA Specialist Dow Jones, Inc blog.jesschadwick.com @jchadwick
  • We thank the following companies for their gracious sponsorship Platinum Sponsor Gold Sponsors Silver Sponsors
  •  
  •  
  •  
  • What is an “automated unit test”? What is a “unit”?
  • Automated Tests…
    • Ensure components work as designed
    • Guard against regressions
    • Exercise the system
    • Expose how the system works
      • Documentation
  • Automated Unit Tests are…
    • Fast
    • Deterministic
    • Independent
    • Repeatable
    • Focused
  • Unit tests…
    • Do not cross application / process boundaries
  • INTEGRATION TESTS
  • Integration Tests…
    • Ensure two or more system components work together
    • Cross application / process boundaries
    • Are unreliable (non-deterministic)
      • Encourage ignoring failing tests
      • This is very bad !
  • DEMO: A SAMPLE UNIT TEST
  • TEST DOUBLES
    • Mocks and Stubs and Fakes… oh my!
  • Test Doubles
    • Stand in for production components
    • Provide deterministic behavior
    • Provide control over testing environment
  • Source: Unit Testing: Exploring The Continuum Of Test Doubles MSDN Magazine, September, 2007
  • CODE COVERAGE
  • Code Coverage is…
    • The degree to which source code is tested
  • RETROFITTING EXISTING CODE WITH TESTS
  •  
  • UNIT TEST ANTI-PATTERNS
  • !! Warning !!
  • Unit Test Anti-Patterns and Smells
    • Test multiple components at once
    • Slow
      • Cross application / process boundaries
    • Depend on other tests or external interaction (non-deterministic)
  • Unit Test Anti-Patterns and Smells
    • Multiple assertions
    • No assertions
    • Unclear / vague assertions
    • Logging / Console.WriteLine()
  • TEST-DRIVEN DEVELOPMENT
  • A different way of thinking
    • Part of Agile / Extreme Programming beliefs
    • Tests drive system design
      • TDD = “Test-Driven Design”
      • “ How am I going to test this?”
    • Helps create loosely-coupled components
  • Test-First Development
    • No code can be written unless driven by a failing test
    • Red – Green - Refactor
  • TDD Pair Programming Game
    • Player 1: Write failing test
    • Player 2: Make failing test pass
    • Player 1: Refactor
    • … repeat!
  • IDEAS TO TAKE HOME
  •  
  •  
  • FOLLOW-UP SESSION: LEVERAGING CONTINUOUS INTEGRATION FOR FUN AND PROFIT PALACE, 2:30 – 3:45 (RIGHT NOW!)
  • Resources
    • My Blog: http://blog.jesschadwick.com
    • Unit Testing Frameworks
      • Team System / MS Test
      • NUnit: http://www.nunit.org
    • Visual Studio Add-ins
      • Test-Driven.Net: http://www.testdriven.net
      • ReSharper: http://www.jetbrains.com
    • Mock Frameworks
      • Moq, Rhino Mocks, NMock, TypeMock, NUnit Mocks, DotNetMock, EasyMock.NET
  •