Download presentation
Presentation is loading. Please wait.
Published byPolly Burns Modified over 9 years ago
1
Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support
2
Agenda What is Test-Driven Development? How to do TDD TDD and Visual Studio 2005 What now? More Information Q&A
3
What is TDD? “Test-Driven Development seeks specification, not validation, letting you think through your design before you write your functional code” - Scott Ambler “Test-Driven Development is a powerful way to produce well designed code with fewer defects” - Martin Fowler
4
What is TDD? ‘History’: –The inner loop of Extreme Programming TDD is: –A design method (and more) TDD is not: –Just writing tests first –A guarantee of quality –Unit testing
5
What is TDD? TDD as a Design Method: –Evolutional –Baby steps –Iterative
6
What is TDD? Evolutional: –No Analysis and Design first –Resilience when requirements are discovered or change
7
What is TDD? Baby Steps: –One test at the time –Avoid complex code –Code quickly Fix the current test –The majority of invested time should be spend on refactoring
8
What is TDD? Iterative Update test list Pick a test Write the test Get the code to compile and FAIL See the test fail Make the code pass the test Refactor Run all tests
9
How to do TDD Updating the Test List –Add small portions of functionality –Add extra test cases –Do not try to make the list complete from the start –Prioritize the tests Risk, ability, … –Do this during the entire process Do NOT get sidetracked!
10
How to do TDD Pick a Test –Pick the single test on top of the test list
11
How to do TDD Write the Test –Keep the code as clean as possible –Update the test list instead of coding extra tests DEMO
12
Background Information New Test Projects can be created like any other kind of Project New Test Projects can be generated: –Right Click a class or method and choose ‘Generate Tests’. The resulting dialog will allow you to save the Unit Tests in a new Test Project.
13
How to do TDD Get the Code to Compile and FAIL –Add a method stub that throws an exception NotImplementedException DEMO
14
How to do TDD See the Test Fail –You want to be sure it fails: Test the test… DEMO
15
Background Information To run Unit Tests: –Build the solution –In the Test menu open Manage and Execute Tests –Check all tests that should be run and click the ‘Run Checked Tests’ button or ‘Debug Checked Tests’ button
16
How to do TDD Make the Code Pass the Test –Don’t worry too much about ‘clean’ code Get the work done Do NOT add code that is not being tested Do NOT use too many stubs/mockups DEMO
17
How to do TDD Refactor –Cleaning up –Remodeling without changing external behavior This is where the Unit Tests prove their use –Allows easy addition of new code –Breaking down large methods/classes –Removing duplicates –Reordering code DEMO
18
Background Information Right-clicking an identifier allows you to rename the identifier Right-clicking a selection of code allows you to promote the selection to a method Right-clicking a method name allows you to reorder the parameters Right-clicking a local variable allows you to promote it to an instance field or parameter
19
How to do TDD Run All Tests –Making sure you didn’t break the solution –Theoretically: Always run all tests This might take to long always run all tests when making a daily build DEMO
20
TDD and Visual Studio 2005 From the Demo: –Unit Testing Generating stubs Generating tests Debugging –Coverage checking –Refactoring
21
TDD and Visual Studio 2005 Visual Studio Also Allows: –‘GUI’ testing –Load testing (Web Applications) –Performance monitoring Team System Allows to: –keep track of work items –keep track of progress –force the tests to run successfully before enabling to check-in the code
22
TDD and Visual Studio 2005 Visual Studio 2005 Delivers the Tools –It does NOT force you to use them –They can be used in ANY kind of software development process (MSF, RUP, XP, …)
23
What now? Developers: –Learn to Refactor –Learn Unit Testing –Learn Whidbey Technical Project Leaders: –Learn/adopt a Software Development Method –Learn Visual Studio Team System/Foundation Server
24
More Information http://www.infosupport.com http://msdn.microsoft.com http://www.testdriven.com “Refactoring: Improving the Design of Existing Code” - Martin Fowler
25
More Information MSDN Fast Track –http://www.microsoft.nl/msdnfasttrack –Technical Seminars (1 day) & Technical Training (3-5 days) SQL Server Database Development Visual Studio Team System SQL Server Business Intelligence Smart Client Development Web Development
26
Q&A
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.