Top Banner
Test-Driven Development With Visual Studio 2005 Erno de Weerd [email protected] Info Support
23

Test-Driven Development With Visual Studio 2005 Erno de Weerd [email protected] Info Support.

Dec 24, 2015

Download

Documents

Polly Burns
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

Test-Driven Development With Visual Studio 2005

Erno de [email protected]

Info Support

Page 2: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

Agenda

• What is Test-Driven Development?

• How to do TDD

• TDD and Visual Studio 2005

• What now?

• More Information

• Q&A

Page 3: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 4: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 5: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

What is TDD?

• TDD as a Design Method:– Evolutional– Baby steps– Iterative

Page 6: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

What is TDD?

• Evolutional:– No Analysis and Design first– Resilience when requirements are discovered

or change

Page 7: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 8: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 9: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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!

Page 10: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

How to do TDD

• Pick a Test– Pick the single test on top of the test list

Page 11: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

How to do TDD

• Write the Test– Keep the code as clean as possible– Update the test list instead of coding extra

tests

DEMODEMO DEMODEMO

Page 12: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

How to do TDD

• Get the Code to Compile and FAIL– Add a method stub that throws an exception

• NotImplementedException

DEMODEMO DEMODEMO

Page 13: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

How to do TDD

• See the Test Fail– You want to be sure it fails: Test the test…

DEMODEMO DEMODEMO

Page 14: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

DEMODEMO DEMODEMO

Page 15: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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 DEMODEMO DEMODEMO

Page 16: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

DEMODEMO DEMODEMO

Page 17: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

TDD and Visual Studio 2005

• From the Demo:– Unit Testing

• Generating stubs• Generating tests• Debugging

– Coverage checking– Refactoring

Page 18: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 19: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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, …)

Page 20: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 21: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

More Information

• http://www.infosupport.com

• http://msdn.microsoft.com

• http://www.testdriven.com

• “Refactoring: Improving the Design of Existing Code” - Martin Fowler

Page 22: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

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

Page 23: Test-Driven Development With Visual Studio 2005 Erno de Weerd ernow@infosupport.com Info Support.

Q&A