SlideShare a Scribd company logo
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

More Related Content

What's hot (20)

PPT
Test Driven Development
Sachithra Gayan
 
PPT
TDD (Test Driven Design)
nedirtv
 
PPTX
Project Onion unit test environment
Abhinav Jha
 
PPT
Presentation_TDD
Raihan Masud
 
PPT
Nguyenvandungb seminar
dunglinh111
 
PDF
A Not-So-Serious Introduction to Test Driven Development (TDD)
CodeOps Technologies LLP
 
PPTX
TDD Basics with Angular.js and Jasmine
Luis Sánchez Castellanos
 
PPTX
Test driven development
Nascenia IT
 
PPTX
Unit Testing And Mocking
Joe Wilson
 
PPT
Introduction to test programming
openfinanceDev
 
PPTX
Unit testing solid fundamentals
Milan Vukoje
 
PDF
Test Driven Development (TDD)
David Ehringer
 
PDF
Alexandru Bolboaca - Unit Testing from the Trenches
Mozaic Works
 
PPTX
Code review at large scale
Mikalai Alimenkou
 
PPT
Test Driven Development
guestc8093a6
 
PPTX
Continous testing for grails
winkler1
 
PPTX
Mock driven development using .NET
Puneet Ghanshani
 
PPTX
Adopting Agile
Coverity
 
PPTX
Unit Testing in Action - C#, NUnit, and Moq
XPDays
 
PPTX
Test-Driven Development In Action
Jon Kruger
 
Test Driven Development
Sachithra Gayan
 
TDD (Test Driven Design)
nedirtv
 
Project Onion unit test environment
Abhinav Jha
 
Presentation_TDD
Raihan Masud
 
Nguyenvandungb seminar
dunglinh111
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
CodeOps Technologies LLP
 
TDD Basics with Angular.js and Jasmine
Luis Sánchez Castellanos
 
Test driven development
Nascenia IT
 
Unit Testing And Mocking
Joe Wilson
 
Introduction to test programming
openfinanceDev
 
Unit testing solid fundamentals
Milan Vukoje
 
Test Driven Development (TDD)
David Ehringer
 
Alexandru Bolboaca - Unit Testing from the Trenches
Mozaic Works
 
Code review at large scale
Mikalai Alimenkou
 
Test Driven Development
guestc8093a6
 
Continous testing for grails
winkler1
 
Mock driven development using .NET
Puneet Ghanshani
 
Adopting Agile
Coverity
 
Unit Testing in Action - C#, NUnit, and Moq
XPDays
 
Test-Driven Development In Action
Jon Kruger
 

Similar to Automated Unit Testing and TDD (20)

PPT
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
PPTX
Test driven development
namkha87
 
PPT
Test-Driven Development
adrianmitev
 
PPTX
Software presentation
JennaPrengle
 
PDF
Unit testing (Exploring the other side as a tester)
Abhijeet Vaikar
 
PPT
Reduce Development Cost with Test Driven Development
sthicks14
 
PPTX
Test driven development(tdd)
Omar Youssef Shiha
 
PDF
The Essentials Of Test Driven Development
Rock Interview
 
PPT
Introduction to Test Driven Development
Michael Denomy
 
PPTX
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
PDF
Markus Clermont - Surviving in an Agile Environment - Google - SoftTest Ireland
David O'Dowd
 
PPTX
Test Driven Development
bhochhi
 
PPT
Test-Driven Development
Effective
 
PPT
Test-Driven Development
EffectiveUI
 
PPT
Test Driven Development
John Blanco
 
PPS
Unit Testing
Anuj Arora
 
PPS
Why Unit Testingl
priya_trivedi
 
PPS
Why Unit Testingl
priya_trivedi
 
PPS
Why unit testingl
Priya Sharma
 
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Test driven development
namkha87
 
Test-Driven Development
adrianmitev
 
Software presentation
JennaPrengle
 
Unit testing (Exploring the other side as a tester)
Abhijeet Vaikar
 
Reduce Development Cost with Test Driven Development
sthicks14
 
Test driven development(tdd)
Omar Youssef Shiha
 
The Essentials Of Test Driven Development
Rock Interview
 
Introduction to Test Driven Development
Michael Denomy
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
Markus Clermont - Surviving in an Agile Environment - Google - SoftTest Ireland
David O'Dowd
 
Test Driven Development
bhochhi
 
Test-Driven Development
Effective
 
Test-Driven Development
EffectiveUI
 
Test Driven Development
John Blanco
 
Unit Testing
Anuj Arora
 
Why Unit Testingl
priya_trivedi
 
Why Unit Testingl
priya_trivedi
 
Why unit testingl
Priya Sharma
 
Ad

More from Greg Sohl (11)

PPTX
A DSL for Your API
Greg Sohl
 
PPT
.NET Overview
Greg Sohl
 
PPTX
Cool .NET tools, techniques and libraries
Greg Sohl
 
PPTX
Net serialization
Greg Sohl
 
PPTX
RESTful APIs in .NET
Greg Sohl
 
PPTX
A great clash of symbols
Greg Sohl
 
PPTX
What’s new in Visual Studio 2010 debugging
Greg Sohl
 
PPT
Analyzing .Net Application Memory Usage And Issues
Greg Sohl
 
PPT
Application Security Part 1 Threat Defense In Client Server Applications ...
Greg Sohl
 
PPT
.NET Recommended Resources
Greg Sohl
 
PPT
Object Oriented Programming In .Net
Greg Sohl
 
A DSL for Your API
Greg Sohl
 
.NET Overview
Greg Sohl
 
Cool .NET tools, techniques and libraries
Greg Sohl
 
Net serialization
Greg Sohl
 
RESTful APIs in .NET
Greg Sohl
 
A great clash of symbols
Greg Sohl
 
What’s new in Visual Studio 2010 debugging
Greg Sohl
 
Analyzing .Net Application Memory Usage And Issues
Greg Sohl
 
Application Security Part 1 Threat Defense In Client Server Applications ...
Greg Sohl
 
.NET Recommended Resources
Greg Sohl
 
Object Oriented Programming In .Net
Greg Sohl
 
Ad

Automated Unit Testing and TDD

  • 1. Unit Testing and Test Driven Development Presented By Greg Sohl
  • 2. 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
  • 3. 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
  • 4. 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?
  • 5. 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
  • 8. Testing - Before and After
  • 9. TDD
  • 11. Test Parts The 3 A’s Arrange, Act, Assert [Test] Public void Send_SingleRecipient_Success { EmailManager emailManager = new EmailManager(); bool result = emailManager.Send(“[email protected]”, “[email protected]”, “Hello”, “message”); Assert.AreEqual(true, result, “The email was not successfully sent”); } <=Arrange <=Act <=Assert
  • 13. 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
  • 14. 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!
  • 15. 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?
  • 16. 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
  • 17. TDD Helps… Understanding the Problem Code Coverage Design Incremental Development
  • 18. Different Than Integration Tests Doesn’t rely on external resources Exercise only a single unit of code
  • 21. 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?
  • 22. Effective Unit Testing Trustworthy Maintainable Readable
  • 23. Writing Testable Code Use interfaces Dependency injection Focused methods Refactoring your code if it is not testable
  • 25. Unit Testing Tools nUnit MS Test mbUnit xUnit
  • 26. References Book: The Art of Unit Testing – Roy Osherove
  • 27. Other Useful Info Database Testing Article - http://bit.ly/bVMvxq Article - http://bit.ly/aHUMWW Web Page Testing WinForm Testing White NUnitForms