SlideShare a Scribd company logo
Test-Driven Development
            &
 Continuous Integration
               Hao-Cheng Lee

     本著作係依據創用 CC Attribution-ShareAlike 3.0 Unported
     授權條款進行授權。如欲瀏覽本授權條款之副本,請造訪
    http://creativecommons.org/licenses/by-sa/3.0/ ,或寄信至
       Creative Commons, 171 Second Street, Suite 300, San
                 Francisco, California, 94105, USA 。
About me

● Hao-Cheng Lee
● Java Engineer for 7+ years
● Quality Engineer@Yahoo (till yesterday ;-))
● Interested in Java, Scala, TDD, CI
● email: haocheng.lee@gmail.com
● twitter: https://twitter.com/#!/haocheng
Agenda

● What is TDD?
● Why use TDD?
● How to do TDD?
● What is CI?
● Why use CI?
● TDD + CI
TDD
    =
   TFD
    +
Refactoring
Test driven development_continuous_integration
Not about
writing tests...
TDD is about
writing better
     code
from http://ch.englishbaby.com/forum/LifeTalk/thread/441379
Test Myths
I have no time
   for testing
Technical Debt




 from http://www.freedebtadvice-uk.com/
My code is
BUG-FREE!
from http://vincentshy.pixnet.net/blog/post/5397455
QA will do the
   testing
Black Box Testing




 from http://www.jasonser.com/marketing-black-box/
http://www.ocoee.org/Departments/HR/
Faster



from http://cllctr.com/view/c2fdb4d2625e109069c843ea1bb99e50
from Test Driven Development Tutorial by Kirrily Robert
Faster

● Shorter release cycle

● Automation saves time

● Find bugs earlier
Better




from http://www.nataliedee.com/archives/2005/sep/
Better

● Greater code coverage

● The courage to refactor

● Prevent regression bugs

● Improve your design
"I'm not a great programmer;
I'm just a good programmer
with great habits."
                  - Kent Beck
Testing the Old Way
TDD
TDD
How to do TDD?

● Design: figure out what you want to do
● Test: write a test to express the design
   ○ It should FAIL
● Implement: write the code
● Test again
   ○ It should PASS
Design

We need a method add(), which
 takes two parameters and add
them together, then it will return
           the result.
Test
FAIL
java.lang.AssertionError: expected:<2> but was:<0>
...
at tw.idv.haocheng.play.
CalculatorTest.one_plus_one_is_two
(CalculatorTest.java:20)
Implement
PASS
Write the least code
to make the test pass
More Test
FAIL
java.lang.AssertionError: expected:<4> but was:<2>
...
at tw.idv.haocheng.play.
CalculatorTest.two_plus_two_is_four
(CalculatorTest.java:25)
Implement
PASS
Design

The add() method only accept
      positive numbers
Test
FAIL
java.lang.AssertionError: IllegalArgumentException expected
at org.junit.Assert.fail(Assert.java:91)
at tw.idv.haocheng.play.
CalculatorTest.negative_numbers_will_throw_exception
(CalculatorTest.java:32)
Implement
PASS
Unit Test Frameworks

● Java - JUni
● Python - PyUnit
● PHP - PHPUnit
● Ruby - Test:Unit
● Javascript - Jasmine
● .Net - NUnit
Good Test

● One test per scenario
● Test in isolation
● Readability
● Minimum Test Fixture
● Repeatable
Bad Smell

● NO Assert/Meaningless Assert
● High maintenance cost
● Interacting Tests
● Require manual debugging
● Evil Singleton
When is enough enough?

● One Test per class
● Testing the feature
● Find bugs, add tests
● Skip Getter/Setter if generated
● Skip Private methods
● Code coverage
There's No Silver Bullet




from http://www.penn-olson.com/2009/12/22/social-media-the-silver-bullet/
It takes time...



from http://chunkeat626.blogspot.com/2010_11_01_archive.html
Need to
maintain tests
TDD is not suitable for...
   from http://www.flickr.com/photos/ilike/2443295369/
from http://tw.gamelet.com/game.do?code=heroes
from http://dilbert.com/
Continuous
Integration
Continuous Integration is a software
development practice where members
of a team integrate their work
frequently, usually each person
integrates at least daily – leading to
multiple integrations per day.
                        -- Martin Fowler
Why CI?

● Rapid Feedback
● Reduced Risk
● Collective Ownership
● Continuous Deployment
● Offload from people
Why TDD + CI?
Effective tests
    must be automated




from http://www.laurentbrouat.com/why-you-should-stop-sending-auto-dms/automated/
Write once, run often

● Write tests once
● Run frequently
● No human input
● Common output
Best Practices of CI

● Single Source Repository
● Commit often
● Make Your Build Self-Testing
● Automate the Build
● Build fast
Extensible continuous integration
             server
What is Jenkins?

● Open-source CI server
● Easy to install and use
● Extensibility
Why Jenkins?

● GUI to manage

● Strong community and eco-system

● Distributed builds

● Open Source and Free!
mailing list subscription is increasing
GitHub members is also increasing
Basic Features

● Notice a change
● Check out source code
● Execute builds/tests
● Record and publish results
● Notify developers
CI Overview




          from Continuous integration with Hudson
Notice a change

● Build Periodically
● Depend on other projects
● Poll SCM
  ○ Subversion Push vs. Pull
Check out source code

● Subversion
● CVS
● Git
● Mercurial
● Perforce
Execute builds/tests

● Java
  ○ Ant, Maven, Gradle

● .Net
  ○ MSBuild, PowerShell

● Shell Script
  ○ Python, Ruby, Groovy
Record and publish results

● JUnit
● TestNG
● Findbugs
● Cobertura
● Checkstyle
● PMD
Job Status

   Job State:   Job Stability:
Findbugs Integration
Cobertura Integration
Project Relationship
Notify developers

● Twitter
● email
● RSS
● IM
● IDE
● Android/iPhone
● Firefox
Test driven development_continuous_integration
Twitter
Jenkins on Eclipse

Update Site: http://code.google.com/p/hudson-eclipse/
Jenkins on Android

                     ● Android Market
                     ● Jenkins Wiki
eXtreme Feedback Panel plugin
Jenkins Sound plugin
http://wiki.jenkins-ci.org/display/JENKINS/Jenkins+Sounds+plugin
Installation&Upgrade

● Download Tomcat 7

● Download latest jenkins.war

● Put jenkins.war under webapps

● Start Tomcat
Create a Job
Configure a Job
Configure Jenkins
Manage Plugins
Jenkins for non-Java Projects

● Python
● PHP
● Ruby
● .Net
Test driven development_continuous_integration
Reading List

● The Bowling Game Kata
● Unit Testing Guidelines
● Why are we embarrassed to admit that we don’t know how
  to write tests? (中譯版本)
● "The Clean Code Talks -- Unit Testing"
● Top 10 things which make your code hard to test
References - Test-Driven Development

● Test Driven Development Tutorial by Kirrily Robert
● Engineer Notebook: An Extreme Programming Episode by
  Robert C. Martin and Robert S. Koss
● Technical Debt by Martin Fowler
● InfoQ: Testing Misconceptions by Liam O'Connor
● Unit Test Isolation
● Erratic Test
● Singletons are Evil
● RSpec 讓你愛上寫測試
References - Continuous Integration

● Jenkins: http://jenkins-ci.org/
● Mailing List: http://groups.google.com/group/jenkinsci-
  users
● Wiki: http://wiki.jenkins-ci.org/
● Follow @jenkinsci on Twitter
● Continous Integration by Martin Fowler
● Continuous Integration with Hudson - the book
● Continuous Integration with Hudson on JavaWorld
Test driven development_continuous_integration

More Related Content

What's hot (19)

PPT
Improve Development Process with Open Source Software
elliando dias
 
PPTX
Continuous delivery applied
Mike McGarr
 
PDF
Code Review
Tu Hoang
 
PPTX
Test driven development
Nascenia IT
 
PPTX
Code review process with JetBrains UpSource
Oleksii Prohonnyi
 
KEY
Continuous Integration, the minimum viable product
Julian Simpson
 
PDF
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
JAXLondon2014
 
PPTX
TDD That Was Easy!
Kaizenko
 
PDF
Continuous Integration, Continuous Quality, Continuous Delivery
John Ferguson Smart Limited
 
PDF
Improving software quality using Continuous Integration
Wouter Konecny
 
PDF
Agile and test driven development
Ahmed El-Deeb
 
PPT
Continuous integration
amscanne
 
PPTX
Automation and Technical Debt
IBM UrbanCode Products
 
PDF
Test Driven Development (TDD) & Continuous Integration (CI)
Fatkul Amri
 
PPTX
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
PPTX
Test driven development(tdd)
Omar Youssef Shiha
 
PDF
Continuous integration and delivery
Danilo Pianini
 
PPTX
A Brief Introduction to Test-Driven Development
Shawn Jones
 
PPT
Test Driven Development and Automation
Mahesh Salaria
 
Improve Development Process with Open Source Software
elliando dias
 
Continuous delivery applied
Mike McGarr
 
Code Review
Tu Hoang
 
Test driven development
Nascenia IT
 
Code review process with JetBrains UpSource
Oleksii Prohonnyi
 
Continuous Integration, the minimum viable product
Julian Simpson
 
Performance Metrics for your Delivery Pipeline - Wolfgang Gottesheim
JAXLondon2014
 
TDD That Was Easy!
Kaizenko
 
Continuous Integration, Continuous Quality, Continuous Delivery
John Ferguson Smart Limited
 
Improving software quality using Continuous Integration
Wouter Konecny
 
Agile and test driven development
Ahmed El-Deeb
 
Continuous integration
amscanne
 
Automation and Technical Debt
IBM UrbanCode Products
 
Test Driven Development (TDD) & Continuous Integration (CI)
Fatkul Amri
 
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Test driven development(tdd)
Omar Youssef Shiha
 
Continuous integration and delivery
Danilo Pianini
 
A Brief Introduction to Test-Driven Development
Shawn Jones
 
Test Driven Development and Automation
Mahesh Salaria
 

Viewers also liked (9)

PPTX
BizSpark SF Lightning Talk: "Refactoring and Test-Driven Development" by Math...
Mark A
 
PPTX
Art of-unittesting
Eric Tummers
 
PDF
Why Test Driven Development?
Naresh Jain
 
PDF
Behavior Driven Development - How To Start with Behat
imoneytech
 
PPTX
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
PDF
Test Driven Development SpeedRun
Speck&Tech
 
PPTX
TDD - Agile
harinderpisces
 
ODP
Continuous Integration and PHP
Arno Schneider
 
PPTX
Jenkins - From Continuous Integration to Continuous Delivery
Virendra Bhalothia
 
BizSpark SF Lightning Talk: "Refactoring and Test-Driven Development" by Math...
Mark A
 
Art of-unittesting
Eric Tummers
 
Why Test Driven Development?
Naresh Jain
 
Behavior Driven Development - How To Start with Behat
imoneytech
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Elad Elrom
 
Test Driven Development SpeedRun
Speck&Tech
 
TDD - Agile
harinderpisces
 
Continuous Integration and PHP
Arno Schneider
 
Jenkins - From Continuous Integration to Continuous Delivery
Virendra Bhalothia
 
Ad

Similar to Test driven development_continuous_integration (20)

PDF
Test Driven Development with PHP
Rogério Vicente
 
PPTX
Test-Driven Development.pptx
Tomas561914
 
PPTX
Test-Driven Development In Action
Jon Kruger
 
PDF
Writing Tests with the Unity Test Framework
Peter Kofler
 
PDF
Test driven development - Zombie proof your code
Pascal Larocque
 
PPTX
Creating a reasonable project boilerplate
Stanislav Petrov
 
PDF
GTAC 2015
Dino Su
 
PPTX
Tdd is not about testing (C++ version)
Gianluca Padovani
 
PDF
Put "fast" back in "fast feedback"
Lars Thorup
 
PDF
TDD and Simple Design Workshop - Session 1 - March 2019
Paulo Clavijo
 
ODP
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 
PPTX
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
PDF
Python and test
Micron Technology
 
PDF
UPC Plone Testing Talk
Timo Stollenwerk
 
PDF
Keeping code clean
Brett Child
 
PDF
Test Driven Development Methodology and Philosophy
Vijay Kumbhar
 
PPTX
How to establish ways of working that allows shifting-left of the automation ...
Max Barrass
 
ODP
Moving to tdd bdd
Kim Carter
 
PPTX
Tdd is not about testing (OOP)
Gianluca Padovani
 
PDF
End-end tests as first class citizens - SeleniumConf 2020
Abhijeet Vaikar
 
Test Driven Development with PHP
Rogério Vicente
 
Test-Driven Development.pptx
Tomas561914
 
Test-Driven Development In Action
Jon Kruger
 
Writing Tests with the Unity Test Framework
Peter Kofler
 
Test driven development - Zombie proof your code
Pascal Larocque
 
Creating a reasonable project boilerplate
Stanislav Petrov
 
GTAC 2015
Dino Su
 
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Put "fast" back in "fast feedback"
Lars Thorup
 
TDD and Simple Design Workshop - Session 1 - March 2019
Paulo Clavijo
 
xUnit and TDD: Why and How in Enterprise Software, August 2012
Justin Gordon
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Iranian Domain-Driven Design Community
 
Python and test
Micron Technology
 
UPC Plone Testing Talk
Timo Stollenwerk
 
Keeping code clean
Brett Child
 
Test Driven Development Methodology and Philosophy
Vijay Kumbhar
 
How to establish ways of working that allows shifting-left of the automation ...
Max Barrass
 
Moving to tdd bdd
Kim Carter
 
Tdd is not about testing (OOP)
Gianluca Padovani
 
End-end tests as first class citizens - SeleniumConf 2020
Abhijeet Vaikar
 
Ad

Recently uploaded (20)

PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 

Test driven development_continuous_integration