SlideShare a Scribd company logo
TDD: Test Driven Developmentwith Visual Studio 2010Stefano Paluellostefano.paluello@pastesoft.comhttp://stefanopaluello.wordpress.comTwitter: @palutz
Test Driven DevelopmentTest-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: the developer writes a failing automated test case that defines a desired improvement or new function (RED)produces code to pass that test (GREEN)finally refactors the new code to acceptable standards (REFACTOR)[Wikipedia]
Test Driven DevelopmentTest Driven Development is one of the Extreme Programming principles (actually is the first one), but can be used also by itselfTDD is a CHANGE OF APPROACH for developers, is a new MINDSET, from writing code and then testing it (if there is enough time) to writing the test first and then writing the code to satisfy the test
Why do I need TDD?
Before TDD…The industry “standard” behavior was to write the code, and then write the tests. This leads to lots of applications without tests at allAlso the “good” applications with some tests written, weren’t (aren’t!!!) able to know whether the new code has broken the existing features
Typical result?
The new approach…Why do we have to stick on that plan?Kent Beck introduced a new method, inside his book about Extreme Programming (XP), in which he proposed to reverse this order by starting with unit tests and then writing the implementation.
Why TDD is good?Thinking about the tests pushes the developer to understand better the gathered requirementsWith the tests defined, the developer can focus on writing ONLY the code to satisfy them (reduce the over-engineered code, or dead-code)The unit tests help to check that any new modification won’t break the existing features
TDD is good (2)TDD speed-up your code! Ok, writing a whole set of code to test your program could appear as too much work, but with test you can trust your code more and you can have a quick feedback about your design and how your objects behave. When all tests have succeeded, you don’t need to spend so much time debugging the tested code.
TDD is notTest Driven Development is good, not God! Test Driven Development isn’t a magic stick that will solve ALL your problemsTest Driven Development is not working if there is not a REALLY mind shift
TDD != Unit Test Ok, this could be a bit confusing but…Test Driven Development is a process, is a mindset, a different approach, focusing on isolated test case to drive designUnit Test is a procedure, a part of the test process
How to justify TDD to PM	Microsoft just published a research report where was pointed out that using TDD, the bugs and defects are reduced from 40% to 90% (nice code was made before!  )http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf
How to justify TDD to Dev Team LeadTDD increase the software’s flexibilityTo be testable, a codebase using TDD is more decoupled and for this reason also adding more features is easier
How to justify TDD to…Stop thinking and justify!Just CODE!
Ops, some advices before code…Write simple test that verify only ONE behaviorAvoid dependencies between testsOne test class for every class within the production codeUse test initialization code before and test cleanup code after running your test (sealed context)Verify that all the tests are passed before move to another feature testMaximize the number of automated tests
TDD with Visual Studio
DemoUnit test with Visual Studio 2010
Demo RecapDespite the Intellisense, Visual Studio 2010 has some tools that help you to focus on TDDUsing Code Coverage, Visual Studio will show you the effectiveness of your tests
DemoWeb test with Visual Studio 2010
Some test “tools” for VS2010Code Contractsallow you to explicitly declare the preconditions, postconditions and invariant part of your codethis improves also the testing via runtime checking (injecting the contracts)it comes from Devlabs and it was an external assemblies for .Net 3.5, now included in .Net 4.0
VS2010 tools (2)Pex and MolesInside the Visual Studio 2010 Power tools extensionPex automatically generates test suites with high code coverage.Right from the Visual Studio code editor, Pex finds interesting input-output values of your methods (white box testing), which you can save as a small test suite with high code coverage. Microsoft Pex is a Visual Studio add-in for testing .NET Framework applications.Moles allows to replace any .NET method with a delegate. Moles supports unit testing by providing isolation by way of detours and stubs. The Moles framework is provided with Pex, or can be installed by itself as a Microsoft Visual Studio add-in (example test Asp.Net and Sharepoint applications!)
Contracts and Pex together
&Programmazione per Device:da Embedded a DesktopDomande  & Risposte

More Related Content

What's hot (20)

PPS
Why Unit Testingl
priya_trivedi
 
PPTX
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
Thomas Weller
 
PPTX
Unit Testing in Java
Ahmed M. Gomaa
 
PDF
iOS Test-Driven Development
Pablo Villar
 
PPS
JUnit Presentation
priya_trivedi
 
PPTX
Principles and patterns for test driven development
Stephen Fuqua
 
PPTX
Unit tests and TDD
Roman Okolovich
 
PDF
Software Testing
AdroitLogic
 
PDF
Testing Java applications with Maveryx
Maveryx
 
DOCX
Test driven development and unit testing with examples in C++
Hong Le Van
 
PPTX
Test-Driven Development
John Blum
 
PPT
J Unit
guest333f37c3
 
PPTX
Unit Testing Full@
Alex Borsuk
 
PDF
Unit and integration Testing
David Berliner
 
PDF
Test Driven Development (TDD)
David Ehringer
 
PDF
Behavior Driven Development with SpecFlow
Rachid Kherrazi
 
PDF
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
InfinIT - Innovationsnetværket for it
 
PDF
Write readable tests
Marian Wamsiedel
 
PPTX
Tdd & unit test
GomathiNayagam S
 
PPTX
Unit Testing Android Applications
Rody Middelkoop
 
Why Unit Testingl
priya_trivedi
 
Introduction to testing with MSTest, Visual Studio, and Team Foundation Serve...
Thomas Weller
 
Unit Testing in Java
Ahmed M. Gomaa
 
iOS Test-Driven Development
Pablo Villar
 
JUnit Presentation
priya_trivedi
 
Principles and patterns for test driven development
Stephen Fuqua
 
Unit tests and TDD
Roman Okolovich
 
Software Testing
AdroitLogic
 
Testing Java applications with Maveryx
Maveryx
 
Test driven development and unit testing with examples in C++
Hong Le Van
 
Test-Driven Development
John Blum
 
Unit Testing Full@
Alex Borsuk
 
Unit and integration Testing
David Berliner
 
Test Driven Development (TDD)
David Ehringer
 
Behavior Driven Development with SpecFlow
Rachid Kherrazi
 
Test Automation and Keyword-driven testing af Brian Nielsen, CISS/AAU
InfinIT - Innovationsnetværket for it
 
Write readable tests
Marian Wamsiedel
 
Tdd & unit test
GomathiNayagam S
 
Unit Testing Android Applications
Rody Middelkoop
 

Similar to TDD with Visual Studio 2010 (20)

DOCX
Tutorial test driven development with Visual Studio 2012
Hong Le Van
 
PPTX
TDD - Agile
harinderpisces
 
PPTX
Test Driven Development
bhochhi
 
PPT
Test-Driven Development
adrianmitev
 
PDF
The Essentials Of Test Driven Development
Rock Interview
 
PPT
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
PPTX
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
PPTX
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
PPT
Presentation_TDD
Raihan Masud
 
PPTX
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
PDF
Test driven development and react js application go hand in hand
Katy Slemon
 
PPTX
Test Driven Development
Rajesh Kumar
 
ODP
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 
PPTX
TDD- Test Driven Development
Liza Antoun
 
PPTX
Test driven development(tdd)
Omar Youssef Shiha
 
PDF
A Study: The Analysis of Test Driven Development And Design Driven Test
Editor IJMTER
 
PDF
Python and test
Micron Technology
 
PDF
Software Development Standard Operating Procedure
rupeshchanchal
 
PDF
TDD vs BDD_ Which Development Approach is Best for Your Project.pdf
Steve Wortham
 
Tutorial test driven development with Visual Studio 2012
Hong Le Van
 
TDD - Agile
harinderpisces
 
Test Driven Development
bhochhi
 
Test-Driven Development
adrianmitev
 
The Essentials Of Test Driven Development
Rock Interview
 
Test Driven Development - Overview and Adoption
Pyxis Technologies
 
Test Driven Development (TDD) Preso 360|Flex 2010
guest5639fa9
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
Presentation_TDD
Raihan Masud
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
Test driven development and react js application go hand in hand
Katy Slemon
 
Test Driven Development
Rajesh Kumar
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 
TDD- Test Driven Development
Liza Antoun
 
Test driven development(tdd)
Omar Youssef Shiha
 
A Study: The Analysis of Test Driven Development And Design Driven Test
Editor IJMTER
 
Python and test
Micron Technology
 
Software Development Standard Operating Procedure
rupeshchanchal
 
TDD vs BDD_ Which Development Approach is Best for Your Project.pdf
Steve Wortham
 
Ad

More from Stefano Paluello (10)

PPTX
Clinical Data and AI
Stefano Paluello
 
PPTX
Real scenario: moving a legacy app to the Cloud
Stefano Paluello
 
PPTX
A gentle introduction to the world of BigData and Hadoop
Stefano Paluello
 
PPTX
Grandata
Stefano Paluello
 
PDF
How to use asana
Stefano Paluello
 
PPTX
Using MongoDB with the .Net Framework
Stefano Paluello
 
PDF
Windows Azure Overview
Stefano Paluello
 
PPTX
Asp.Net MVC Intro
Stefano Paluello
 
PPTX
Entity Framework 4
Stefano Paluello
 
PPTX
Teamwork and agile methodologies
Stefano Paluello
 
Clinical Data and AI
Stefano Paluello
 
Real scenario: moving a legacy app to the Cloud
Stefano Paluello
 
A gentle introduction to the world of BigData and Hadoop
Stefano Paluello
 
How to use asana
Stefano Paluello
 
Using MongoDB with the .Net Framework
Stefano Paluello
 
Windows Azure Overview
Stefano Paluello
 
Asp.Net MVC Intro
Stefano Paluello
 
Entity Framework 4
Stefano Paluello
 
Teamwork and agile methodologies
Stefano Paluello
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
July Patch Tuesday
Ivanti
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Python basic programing language for automation
DanialHabibi2
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 

TDD with Visual Studio 2010

  • 1. TDD: Test Driven Developmentwith Visual Studio 2010Stefano [email protected]://stefanopaluello.wordpress.comTwitter: @palutz
  • 2. Test Driven DevelopmentTest-driven development (TDD) is a software development process that relies on the repetition of a very short development cycle: the developer writes a failing automated test case that defines a desired improvement or new function (RED)produces code to pass that test (GREEN)finally refactors the new code to acceptable standards (REFACTOR)[Wikipedia]
  • 3. Test Driven DevelopmentTest Driven Development is one of the Extreme Programming principles (actually is the first one), but can be used also by itselfTDD is a CHANGE OF APPROACH for developers, is a new MINDSET, from writing code and then testing it (if there is enough time) to writing the test first and then writing the code to satisfy the test
  • 4. Why do I need TDD?
  • 5. Before TDD…The industry “standard” behavior was to write the code, and then write the tests. This leads to lots of applications without tests at allAlso the “good” applications with some tests written, weren’t (aren’t!!!) able to know whether the new code has broken the existing features
  • 7. The new approach…Why do we have to stick on that plan?Kent Beck introduced a new method, inside his book about Extreme Programming (XP), in which he proposed to reverse this order by starting with unit tests and then writing the implementation.
  • 8. Why TDD is good?Thinking about the tests pushes the developer to understand better the gathered requirementsWith the tests defined, the developer can focus on writing ONLY the code to satisfy them (reduce the over-engineered code, or dead-code)The unit tests help to check that any new modification won’t break the existing features
  • 9. TDD is good (2)TDD speed-up your code! Ok, writing a whole set of code to test your program could appear as too much work, but with test you can trust your code more and you can have a quick feedback about your design and how your objects behave. When all tests have succeeded, you don’t need to spend so much time debugging the tested code.
  • 10. TDD is notTest Driven Development is good, not God! Test Driven Development isn’t a magic stick that will solve ALL your problemsTest Driven Development is not working if there is not a REALLY mind shift
  • 11. TDD != Unit Test Ok, this could be a bit confusing but…Test Driven Development is a process, is a mindset, a different approach, focusing on isolated test case to drive designUnit Test is a procedure, a part of the test process
  • 12. How to justify TDD to PM Microsoft just published a research report where was pointed out that using TDD, the bugs and defects are reduced from 40% to 90% (nice code was made before!  )http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf
  • 13. How to justify TDD to Dev Team LeadTDD increase the software’s flexibilityTo be testable, a codebase using TDD is more decoupled and for this reason also adding more features is easier
  • 14. How to justify TDD to…Stop thinking and justify!Just CODE!
  • 15. Ops, some advices before code…Write simple test that verify only ONE behaviorAvoid dependencies between testsOne test class for every class within the production codeUse test initialization code before and test cleanup code after running your test (sealed context)Verify that all the tests are passed before move to another feature testMaximize the number of automated tests
  • 17. DemoUnit test with Visual Studio 2010
  • 18. Demo RecapDespite the Intellisense, Visual Studio 2010 has some tools that help you to focus on TDDUsing Code Coverage, Visual Studio will show you the effectiveness of your tests
  • 19. DemoWeb test with Visual Studio 2010
  • 20. Some test “tools” for VS2010Code Contractsallow you to explicitly declare the preconditions, postconditions and invariant part of your codethis improves also the testing via runtime checking (injecting the contracts)it comes from Devlabs and it was an external assemblies for .Net 3.5, now included in .Net 4.0
  • 21. VS2010 tools (2)Pex and MolesInside the Visual Studio 2010 Power tools extensionPex automatically generates test suites with high code coverage.Right from the Visual Studio code editor, Pex finds interesting input-output values of your methods (white box testing), which you can save as a small test suite with high code coverage. Microsoft Pex is a Visual Studio add-in for testing .NET Framework applications.Moles allows to replace any .NET method with a delegate. Moles supports unit testing by providing isolation by way of detours and stubs. The Moles framework is provided with Pex, or can be installed by itself as a Microsoft Visual Studio add-in (example test Asp.Net and Sharepoint applications!)
  • 22. Contracts and Pex together
  • 23. &Programmazione per Device:da Embedded a DesktopDomande & Risposte