Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Test Driven Development      Experiences          nucc
Ideas
Specification?
Specification?  it’s easy...
Specification?    it’s easy...it takes an hour...
Features         The program should do              something...      and should do another thing...
Implementfeature #1 Check
Implement    Implementfeature #1   feature #2 Check        Check
Implement    Implement    Implementfeature #1   feature #2   feature #3 Check        Check        Check
Implement        Implementfeature #2        feature #3 Check             Interface problem...                Ouch, rewrite
What’s your opinion despite of the fact it doesn’t work?
Implement Check
Design           Implement         Check
Design                     Implement         Automated Check              TEST
Test Driven DevelopmentKent BeckSoftware Development ProcessTest-first programming concept
TestDesign          Implement         Test
TestDesign          Implement         Test
Writing test It’s not easy! Harder then implement the feature! It’s fun!
My TDD project http://github.com/nucc/check.it Review tool for GIT repository
Designdescribe "patches/index.html.erb" do it "should have an update repository link to refresh the patch set" do  @reposi...
Designdescribe "calling /update/update_test.git" do before :each do  # move references to initial commit  move_git_referen...
Test your design (failed).*.............*............................F***.....*Failures:  1) Update the repositories calli...
Implement  Write as much code as you need now!           Green your tests!
Implementclass UpdateController < ApplicationController  before_filter :repository_must_be_defined  before_filter :reposit...
Implementdef fetch_origin  ::Grit::Git.git_timeout = 60  repository.fetchenddef update_references  Repository.new(reposito...
Test againUpdate the repositories  for calling an URL    Update the repositories calling /update/update_test.git    should...
TestDesign              Implement          Test         Refactor
Speed
Defect                 Test     Reproduct          Fix                 Test
ToolsJUnit (Java)Google Test + Google Mock (C++)Boost Test Library (C++)RSpec (Ruby)PyUnit
?twitter.com/nucc
Test Driven Development
Upcoming SlideShare
Loading in …5
×

Test Driven Development

471 views

Published on

Test Driven Development on Veszpremi Technology Meetup.

http://blog.bteam.hu/?p=36

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Test Driven Development

  1. 1. Test Driven Development Experiences nucc
  2. 2. Ideas
  3. 3. Specification?
  4. 4. Specification? it’s easy...
  5. 5. Specification? it’s easy...it takes an hour...
  6. 6. Features The program should do something... and should do another thing...
  7. 7. Implementfeature #1 Check
  8. 8. Implement Implementfeature #1 feature #2 Check Check
  9. 9. Implement Implement Implementfeature #1 feature #2 feature #3 Check Check Check
  10. 10. Implement Implementfeature #2 feature #3 Check Interface problem... Ouch, rewrite
  11. 11. What’s your opinion despite of the fact it doesn’t work?
  12. 12. Implement Check
  13. 13. Design Implement Check
  14. 14. Design Implement Automated Check TEST
  15. 15. Test Driven DevelopmentKent BeckSoftware Development ProcessTest-first programming concept
  16. 16. TestDesign Implement Test
  17. 17. TestDesign Implement Test
  18. 18. Writing test It’s not easy! Harder then implement the feature! It’s fun!
  19. 19. My TDD project http://github.com/nucc/check.it Review tool for GIT repository
  20. 20. Designdescribe "patches/index.html.erb" do it "should have an update repository link to refresh the patch set" do @repository = “test.git” render rendered.should have_tag("a.update[href=’/update/test.git’]", :text => "Update the repository") endend
  21. 21. Designdescribe "calling /update/update_test.git" do before :each do # move references to initial commit move_git_reference :test_update_repository_branch1, :f7d10b1... move_git_reference :test_update_repository_branch2, :debf1ef84... end it "should fetch and reset --hard to the origin remote" do fetch :origin get "/update/update_test.git" branch_reference("origin/branch1").should == branch_reference("branch1") branch_reference("origin/branch2").should == branch_reference("branch2") end
  22. 22. Test your design (failed).*.............*............................F***.....*Failures: 1) Update the repositories calling /update/update_test.git shouldfetch and reset --hard to the origin remote Failure/Error:branch_reference("origin/branch1").should == branch_reference("branch1") expected: "f7d10b1380081fa08d96191638606d8d235e24e2" got: "7460e1b30b569cdedcdbaa668e897b2a710fabe0" (using ==) # ./spec/requests/update_the_repository_to_an_url_spec.rb:27 fixed state
  23. 23. Implement Write as much code as you need now! Green your tests!
  24. 24. Implementclass UpdateController < ApplicationController before_filter :repository_must_be_defined before_filter :repository_must_exist def index fetch_origin update_references render_response end ...
  25. 25. Implementdef fetch_origin ::Grit::Git.git_timeout = 60 repository.fetchenddef update_references Repository.new(repository).branches.each do |branch| repository.update_ref({}, "refs/heads/#{branch}", "origin/#branch}") endend
  26. 26. Test againUpdate the repositories for calling an URL Update the repositories calling /update/update_test.git should fetch and reset --hard to the origin remote should reset --hard the branch1 and branch2 in update_test.git should fetch and reset --hard to the origin remote should insert the commits to the database (PENDING: request) should have one minute timeout (PENDING: Not Yet Implemented)
  27. 27. TestDesign Implement Test Refactor
  28. 28. Speed
  29. 29. Defect Test Reproduct Fix Test
  30. 30. ToolsJUnit (Java)Google Test + Google Mock (C++)Boost Test Library (C++)RSpec (Ruby)PyUnit
  31. 31. ?twitter.com/nucc

×