• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Automated Unit Testing and TDD
 

Automated Unit Testing and TDD

on

  • 2,573 views

Slides from a presentation I gave at CRineta (www.crineta.org) at its April '10 meeting.

Slides from a presentation I gave at CRineta (www.crineta.org) at its April '10 meeting.

Statistics

Views

Total Views
2,573
Views on SlideShare
2,557
Embed Views
16

Actions

Likes
2
Downloads
49
Comments
0

4 Embeds 16

http://www.cwi-websoft.com 7
http://www.slideshare.net 4
http://www.linkedin.com 3
http://www.php-talks.com 2

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

    Automated Unit Testing and TDD Automated Unit Testing and TDD Presentation Transcript

    • Unit Testing and Test Driven Development Presented By Greg Sohl
    • Agenda
      • Testing? Dude, I already test.
      • Unit testing and TDD Overview
      • Simple TDD example
        • Calculation Class
      • But I already have code
      • More complex example, with injection
        • File Copy Class
      • Tools
      • Q & A
    • Testing? Dude, I Already Test Do you currently unit test your code? What types of unit tests do you create? CRineta Member Survey, 8/08
    • Unit Testing and TDD The process of designing software by writing a validating client before the code. What is Test-Driven Development (TDD)? Programmatically and continuously validating the correctness the code. What is Automated Unit Testing?
    • Unit Testing and TDD Automated Unit Testing != Test-Driven Development TDD is a way of thinking about your code, but it doesn’t require automated unit testing. Agile processes adapt to change. Unit tests help to manage change in our code. Unit Testing is a key component of the Agile Methodology
    • Unit Testing
    • Writing Tests First
    • Testing - Before and After
    • TDD
    • TDD Demo
    • Test Parts
      • The 3 A’s
        • Arrange, Act, Assert
      • [Test]
      • Public void Send_SingleRecipient_Success
      • {
      • EmailManager emailManager = new EmailManager();
        • bool result = emailManager.Send(“johndoe@home.com”, “sammy@away.net”, “Hello”, “message”);
        • Assert.AreEqual(true, result, “The email was not successfully sent”);
      • }
      <=Arrange <=Act <=Assert
    • Sounds good, but…
    • Misconception #1
      • Won’t writing unit tests increase development time?
        • Unit tests are an investment towards time savings over the lifetime of the project.
        • Provides regression testing when code changes
        • Find bugs early
        • Good tests on fundamental areas saves integration testing time
    • Misconception #2
      • Won’t all my unit tests just get out of date?
        • Unit tests are not parallel to your code like documentation. You will be driving your code with them.
        • TDD is a programming paradigm.
        • Unit tests are not an artifact of your code. They represent how you write it!
    • Misconception #3
      • Won’t the client refuse to pay for it?
        • The client is paying for clean, correct code. Unit testing is the means to that end.
        • Do they pay us to test our code?
        • Do they pay us to use design patterns?
        • Do they pay us to debug our code?
    • Unit Testing Benefits
      • Makes you a user of your software
      • Easier to find bugs
        • Unless your tests have bugs
      • Easier to maintain
        • Except when changes require massive updates to tests
      • Easier to understand
        • Unless the tests are not well written / documented
      • Easier to develop
        • When tests are maintained as part of process
    • TDD Helps…
      • Understanding the Problem
      • Code Coverage
      • Design
      • Incremental Development
    • Different Than Integration Tests
      • Doesn’t rely on external resources
      • Exercise only a single unit of code
    • Good Unit Tests
    • Good Unit Tests
    • Good Unit Tests
      • Ask Yourself:
        • Can I run and get results from a unit test I wrote two weeks or months or years ago?
        • Can any member of my team run and get the results from unit tests I wrote two months ago?
    • Effective Unit Testing
      • Trustworthy
      • Maintainable
      • Readable
    • Writing Testable Code
      • Use interfaces
      • Dependency injection
      • Focused methods
      • Refactoring your code if it is not testable
    • Demo #2
    • Unit Testing Tools
      • nUnit
      • MS Test
      • mbUnit
      • xUnit
    • References
      • Book: The Art of Unit Testing – Roy Osherove
    • Other Useful Info
      • Database Testing
        • Article - http://bit.ly/bVMvxq
        • Article - http://bit.ly/aHUMWW
      • Web Page Testing
      • WinForm Testing
        • White
        • NUnitForms
    • Questions