SlideShare a Scribd company logo
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...
Implement

feature #1




 Check
Implement    Implement

feature #1   feature #2




 Check        Check
Implement    Implement    Implement

feature #1   feature #2   feature #3




 Check        Check        Check
Implement        Implement

feature #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 Development

Kent Beck

Software Development Process

Test-first programming concept
Test




Design          Implement




         Test
Test




Design          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
Test Driven Development
Design
describe "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")
 end
end
Design
describe "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
Test your design (failed)

.*.............*............................F***.....*

Failures:

  1) Update the repositories calling /update/update_test.git should
fetch 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
Implement


  Write as much code as you need now!

           Green your tests!
Implement

class UpdateController < ApplicationController

  before_filter :repository_must_be_defined
  before_filter :repository_must_exist

  def index
    fetch_origin
    update_references
    render_response
  end

  ...
Implement

def fetch_origin
  ::Grit::Git.git_timeout = 60
  repository.fetch
end

def update_references
  Repository.new(repository).branches.each do |branch|
    repository.update_ref({}, "refs/heads/#{branch}", "origin/#branch}")
  end
end
Test again


Update 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)
Test




Design              Implement




          Test




         Refactor
Speed
Defect
                 Test




     Reproduct          Fix




                 Test
Tools

JUnit (Java)

Google Test + Google Mock (C++)

Boost Test Library (C++)

RSpec (Ruby)

PyUnit
?
twitter.com/nucc

More Related Content

ODP
SANER 2015 ERA track: Differential Flame Graphs
PPTX
Deployment Patterns in the Ruby on Rails World
KEY
Ruby and Rails Packaging to Production
PDF
Killer R10K Workflow - PuppetConf 2014
PDF
Automated Testing for Embedded Software in C or C++
ODP
Continuous Delivery of Puppet Manifests
PDF
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
PDF
Виталий Редько "React + Redux: performance & scalability"
SANER 2015 ERA track: Differential Flame Graphs
Deployment Patterns in the Ruby on Rails World
Ruby and Rails Packaging to Production
Killer R10K Workflow - PuppetConf 2014
Automated Testing for Embedded Software in C or C++
Continuous Delivery of Puppet Manifests
Puppet Camp Düsseldorf 2014: Continuously Deliver Your Puppet Code with Jenki...
Виталий Редько "React + Redux: performance & scalability"

What's hot (20)

PDF
100 tests per second - 40 releases per week
PDF
How to integrate front end tool via gruntjs
PDF
Automated acceptance test
PDF
Git basics for beginners
PPT
Testing of javacript
PDF
Python Testing Fundamentals
PDF
Git and git hub
PDF
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
ODP
STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17
 
PPTX
Testing With OutSystems
PPTX
Git in Continuous Deployment
PDF
Drupal contrib module maintaining
PDF
Tp install anything
PDF
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
PDF
CIbox - OpenSource solution for making your #devops better
PDF
DrupalCon Los Angeles - Continuous Integration Toolbox
PPTX
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
PDF
Continuous Integration for Spark Apps by Sean McIntyre
PPTX
Python in Test automation
PDF
Test Driven Development Methodology and Philosophy
100 tests per second - 40 releases per week
How to integrate front end tool via gruntjs
Automated acceptance test
Git basics for beginners
Testing of javacript
Python Testing Fundamentals
Git and git hub
Puppet Camp Sydney 2015: Puppet and AWS is easy right.....?
STAMP: Software Testing Amplification in DevOps, Etienne Sauvage, OW2con'17
 
Testing With OutSystems
Git in Continuous Deployment
Drupal contrib module maintaining
Tp install anything
PuppetConf 2016: Deploying Multi-Tier Windows Applications with Application O...
CIbox - OpenSource solution for making your #devops better
DrupalCon Los Angeles - Continuous Integration Toolbox
Automating Your Way to Greatness by Combining OutSystems CI/CD With the Power...
Continuous Integration for Spark Apps by Sean McIntyre
Python in Test automation
Test Driven Development Methodology and Philosophy
Ad

Viewers also liked (8)

PDF
Shade műhely
PDF
Ruby gems
PDF
Open Academy - Ruby
PDF
Git thinking
PDF
Have2do.it
PDF
Resource and view
PDF
Rails Models
PDF
Munkafolyamatok modellezése OPM segítségével
Shade műhely
Ruby gems
Open Academy - Ruby
Git thinking
Have2do.it
Resource and view
Rails Models
Munkafolyamatok modellezése OPM segítségével
Ad

Similar to Test Driven Development (20)

PDF
Gitlab and Lingvokot
PDF
Jenkins Pipelines
PPTX
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
PDF
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
PPTX
Static Code Analysis PHP[tek] 2023
PDF
Let your tests drive your code
PPT
Simple tools to fight bigger quality battle
PDF
PyCon JP 2024 Streamlining Testing in a Large Python Codebase .pdf
PPTX
Cooking the Cake for Nuget packages
PDF
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
PPTX
Lightning branches at RedMart (Js conf Asia 2014 Talk)
PPTX
Continuous Integration/ Continuous Delivery of web applications
PDF
Continuous Integration/Deployment with Docker and Jenkins
PPTX
Moving from Jenkins 1 to 2 declarative pipeline adventures
PDF
Testing Legacy Rails Apps
PDF
Continuous integration / continuous delivery
PDF
Agile Software Factory - Cloud Expo / DevOps Summit 2014 demo
PDF
Test driven infrastructure
PDF
Deployment Tactics
PDF
Jenkins Pipelines Advanced
Gitlab and Lingvokot
Jenkins Pipelines
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
Static Code Analysis PHP[tek] 2023
Let your tests drive your code
Simple tools to fight bigger quality battle
PyCon JP 2024 Streamlining Testing in a Large Python Codebase .pdf
Cooking the Cake for Nuget packages
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Lightning branches at RedMart (Js conf Asia 2014 Talk)
Continuous Integration/ Continuous Delivery of web applications
Continuous Integration/Deployment with Docker and Jenkins
Moving from Jenkins 1 to 2 declarative pipeline adventures
Testing Legacy Rails Apps
Continuous integration / continuous delivery
Agile Software Factory - Cloud Expo / DevOps Summit 2014 demo
Test driven infrastructure
Deployment Tactics
Jenkins Pipelines Advanced

Recently uploaded (20)

PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation theory and applications.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation theory and applications.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
NewMind AI Weekly Chronicles - August'25 Week I
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
sap open course for s4hana steps from ECC to s4
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Digital-Transformation-Roadmap-for-Companies.pptx

Test Driven Development

  • 1. Test Driven Development Experiences nucc
  • 5. Specification? it’s easy... it takes an hour...
  • 6. Features The program should do something... and should do another thing...
  • 8. Implement Implement feature #1 feature #2 Check Check
  • 9. Implement Implement Implement feature #1 feature #2 feature #3 Check Check Check
  • 10. Implement Implement feature #2 feature #3 Check Interface problem... Ouch, rewrite
  • 11. What’s your opinion despite of the fact it doesn’t work?
  • 13. Design Implement Check
  • 14. Design Implement Automated Check TEST
  • 15. Test Driven Development Kent Beck Software Development Process Test-first programming concept
  • 16. Test Design Implement Test
  • 17. Test Design Implement Test
  • 18. Writing test It’s not easy! Harder then implement the feature! It’s fun!
  • 19. My TDD project http://github.com/nucc/check.it Review tool for GIT repository
  • 21. Design describe "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") end end
  • 22. Design describe "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
  • 23. Test your design (failed) .*.............*............................F***.....* Failures: 1) Update the repositories calling /update/update_test.git should fetch 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
  • 24. Implement Write as much code as you need now! Green your tests!
  • 25. Implement class UpdateController < ApplicationController before_filter :repository_must_be_defined before_filter :repository_must_exist def index fetch_origin update_references render_response end ...
  • 26. Implement def fetch_origin ::Grit::Git.git_timeout = 60 repository.fetch end def update_references Repository.new(repository).branches.each do |branch| repository.update_ref({}, "refs/heads/#{branch}", "origin/#branch}") end end
  • 27. Test again Update 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)
  • 28. Test Design Implement Test Refactor
  • 29. Speed
  • 30. Defect Test Reproduct Fix Test
  • 31. Tools JUnit (Java) Google Test + Google Mock (C++) Boost Test Library (C++) RSpec (Ruby) PyUnit