Your SlideShare is downloading. ×
0
What is TDD?(answer: Test-Driven Development)    … and why you should careClear Lines Consulting · clear-lines.com   11/8/...
Once upon a Time…    Design                                   Implement                                               Test...
Stay buggy, my friends!Clear Lines Consulting · clear-lines.com   11/8/2011 · 3
Start with the tests!                                           If I needed to Add 1 + 1…Clear Lines Consulting · clear-li...
If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){  // Assert  var expectedResult...
If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){  // Act  var actualResult = ca...
If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){  // Arrange  var calculator = ...
If I needed to Add 1 + 1…                                           … Does the code work?Clear Lines Consulting · clear-li...
Testing frameworks       MsTestClear Lines Consulting · clear-lines.com   11/8/2011 · 9
It’s not about Testing»    It’s about writing Code that works, now»    Imagine you had implemented the feature»    … then ...
Why should you care?Clear Lines Consulting · clear-lines.com   11/8/2011 · 11
The dreaded L word                                           © www.dilbert.comClear Lines Consulting · clear-lines.com    ...
“To me, legacy code is simply code without tests.”         Michael Feathers,                   Working Effectively with Le...
Did I break everything?Clear Lines Consulting · clear-lines.com   11/8/2011 · 14
Tests: a Vise holding your code steadyClear Lines Consulting · clear-lines.com   11/8/2011 · 15
A good test is» Fast» Focused» Replicable» AutomatedClear Lines Consulting · clear-lines.com   11/8/2011 · 16
Refactoring: improve the       code structure, without       changing its external       behavior.Clear Lines Consulting ·...
Red, Green, Refactor                                   » Red: write a little test                                     that...
Test-Driven Development is a    way of managing fear during    programming.                         Kent Beck,            ...
The Cast» Me: Mathias Brandewinder       – mathias@clear-lines.com (clear-lines.com/blog)» Frameworks/Tools       – NUnit:...
Upcoming SlideShare
Loading in...5
×

BizSpark SF Lightning Talk: "Refactoring and Test-Driven Development" by Mathias Brandewinder

421

Published on

Presentation from November 2011 BizSparkSF Meetup entitled "Tools, Tools and More Tools!" http://www.bizsparksf.com/events/34653282/

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
421
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "BizSpark SF Lightning Talk: "Refactoring and Test-Driven Development" by Mathias Brandewinder"

  1. 1. What is TDD?(answer: Test-Driven Development) … and why you should careClear Lines Consulting · clear-lines.com 11/8/2011 · 1
  2. 2. Once upon a Time… Design Implement TestClear Lines Consulting · clear-lines.com 11/8/2011 · 2
  3. 3. Stay buggy, my friends!Clear Lines Consulting · clear-lines.com 11/8/2011 · 3
  4. 4. Start with the tests! If I needed to Add 1 + 1…Clear Lines Consulting · clear-lines.com 11/8/2011 · 4
  5. 5. If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){ // Assert var expectedResult = 2; Assert.That(actualResult, Is.EqualTo(expectedResult));} … I would expect the answer to be 2Clear Lines Consulting · clear-lines.com 11/8/2011 · 5
  6. 6. If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){ // Act var actualResult = calculator.Add(1, 1); // Assert var expectedResult = 2; Assert.That(actualResult, Is.EqualTo(expectedResult));} … I would need a CalculatorClear Lines Consulting · clear-lines.com 11/8/2011 · 6
  7. 7. If I needed to Add 1 + 1…[Test]public void When_Adding_One_Plus_One_Answer_Should_Be_Two(){ // Arrange var calculator = new Calculator(); // Act var actualResult = calculator.Add(1, 1); // Assert var expectedResult = 2; Assert.That(actualResult, Is.EqualTo(expectedResult));} … I would need some codeClear Lines Consulting · clear-lines.com 11/8/2011 · 7
  8. 8. If I needed to Add 1 + 1… … Does the code work?Clear Lines Consulting · clear-lines.com 11/8/2011 · 8
  9. 9. Testing frameworks MsTestClear Lines Consulting · clear-lines.com 11/8/2011 · 9
  10. 10. It’s not about Testing» It’s about writing Code that works, now» Imagine you had implemented the feature» … then implement it» Rinse & Repeat until you have no test to writeClear Lines Consulting · clear-lines.com 11/8/2011 · 10
  11. 11. Why should you care?Clear Lines Consulting · clear-lines.com 11/8/2011 · 11
  12. 12. The dreaded L word © www.dilbert.comClear Lines Consulting · clear-lines.com 11/8/2011 · 12
  13. 13. “To me, legacy code is simply code without tests.” Michael Feathers, Working Effectively with Legacy CodeClear Lines Consulting · clear-lines.com 11/8/2011 · 13
  14. 14. Did I break everything?Clear Lines Consulting · clear-lines.com 11/8/2011 · 14
  15. 15. Tests: a Vise holding your code steadyClear Lines Consulting · clear-lines.com 11/8/2011 · 15
  16. 16. A good test is» Fast» Focused» Replicable» AutomatedClear Lines Consulting · clear-lines.com 11/8/2011 · 16
  17. 17. Refactoring: improve the code structure, without changing its external behavior.Clear Lines Consulting · clear-lines.com 11/8/2011 · 17
  18. 18. Red, Green, Refactor » Red: write a little test that doesn’t work » Green: make the test work quickly » Refactor: cleanup time!Clear Lines Consulting · clear-lines.com 11/8/2011 · 18
  19. 19. Test-Driven Development is a way of managing fear during programming. Kent Beck, Test-Driven Development by ExampleClear Lines Consulting · clear-lines.com 11/8/2011 · 19
  20. 20. The Cast» Me: Mathias Brandewinder – mathias@clear-lines.com (clear-lines.com/blog)» Frameworks/Tools – NUnit: www.nunit.org – xUnit: xunit.codeplex.com/ – Resharper: www.jetbrains.com/resharper/» Books – Kent Beck, “Test Driven Development by Example” – Michael Feathers, “Working Effectively with Legacy Code” – Roy Osherove, “The Art of Unit Testing”Clear Lines Consulting · clear-lines.com 11/8/2011 · 20
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×