28
Intro to Test Driven Development Jon Reid @qcoding

Intro to Test Driven Development - Quality Coding · code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Intro to Test Driven Development

Jon Reid@qcoding

http://www.bbc.co.uk/programmes/p05tyrjy/p05tyrgh

Whoare you?

@qcoding

@qcoding

FOR YOU AGILE FOLKS…

@qcoding

http://www.agilescrum.org

@qcoding

Continuous: • TDD • Refactoring • Build • Integration • Collaboration

OUTLINE

• What is TDD? 3 Steps & 3 Laws

• Collaborative Demo

• Costs & Benefits

• How to Get Started

• Q&A

@qcoding

Write a failing test

Make the test pass

Refactor

3 Steps: “TDD Waltz”

@qcoding

3 Laws of TDD

1. You are not allowed to write any production code unless it is to make a failing unit test pass.

2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.

3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

@qcoding

COLLABORATIVE DEMO!

@qcoding

COSTS AND BENEFITS:WHAT DOES RESEARCH SHOW?

@qcoding

Home Publications Research Teaching Students Funding Consulting Family

Software Engineering Research

Laurie Williams

Professor

North Carolina State University Department of Computer Science

890 Oval Drive, Engineering Building 2, Room 3272

Campus Box 8206

Raleigh, NC 27695-8206 USA

Phone: (919)513-4151

Fax: (919)515-7896

Email: williams ~@~ csc.ncsu.edu

resume and bio . . . read more

Laurie Williams is a Professor in the Computer Science Department of the College of Engineering at North Carolina StateUniversity (NCSU). Her research focuses on software security particularly in relation to healthcare IT; agile softwaredevelopment practices and processes; software reliability, software testing and analysis; open source software development;and broadening participation and increasing retention in computer science. Laurie has more than 170 refereed publications.

Laurie leads the Software Engineering Realsearch research group at NCSU. With her students in the Realsearch group, Lauriehas been involved in working collaboratively with high tech industries like ABB Corporation, Cisco, IBM Corporation, Microsoft,Nortel Networks, Red Hat, Sabre Airline Solutions, SAS, Tekelec, and other healthcare IT companies. They also extensivelyevaluate open source software.

Laurie was named an ACM Distinguished Scientist in 2011. Laurie is one of the foremost researchers in agile softwaredevelopment and in the security of healthcare IT applications. She was one of the founders of the first XP/Agile conference,XP Universe, in 2001 in Raleigh which has now grown into the Agile 200x annual conference. She is also the lead author ofthe book Pair Programming Illuminated and a co-editor of Extreme Programming Perspectives. Laurie is also the instructor ofa highly-rated professional agile software development course that has been widely taught in Fortune 500 companies. Shealso is a certified instructor of John Musa's software reliability engineering course, More Reliable Software Faster andCheaper.

Laurie is Laurie is a co-director of the NCSU Science of Security Lablet, the Senior Research Director of the Institute of NextGeneration Systems (ITnG). Laurie is the Director of the North Carolina State University Laboratory for Collaborative SystemDevelopment and the software engineering area representative for the Secure Open Systems Initiative.

Laurie is an NSF CAREER award winner. She is a among a select group of faculty at NCSU to win the Outstanding Teachingaward for her innovative teaching and is an inductee in the NC State's Academy of Outstanding Teachers. In 2009, she washonored to receive the ACM SIGSOFT Influential Educator Award.

Laurie received her Ph.D. in Computer Science from the University of Utah, her MBA from Duke University Fuqua School ofBusiness, and her BS in Industrial Engineering from Lehigh University. She worked for IBM Corporation for nine years inRaleigh, NC and Research Triangle Park, NC before returning to academia.

TDD Studies

@qcoding

@qcoding

@qcoding

@qcoding

@qcoding

http://www.flickr.com/photos/twaddington/2102677592

CohesionCouplingComplexity

⇧21% ⇩10% ⇩31%

@qcoding

Are you willing to pay 15-35% increase in “initial development time” for :

✓40-90% reduction in defects

✓Significantly improved code quality

✓Reduced maintenance costs

http://www.vsellis.com@qcoding

COSTS AND BENEFITS:WHAT’S IN IT FOR CODERS?

@qcoding

Test-first reduces rework…

You have to think more about how to test…

Testable code is the natural result.

https://www.flickr.com/photos/k4cay/2819125024/@qcoding

Adding tests after… takes more effort!

Design interfaces first

Decompose into discrete units

Continual clean-up

http://www.flickr.com/photos/stefan-w/3337072853

TDD ➭ Improved Code

@qcoding

Magical Compiler

http://www.flickr.com/photos/nanagyei/8590967532@qcoding

Safety ➭ Fearlessness!

http://www.flickr.com/photos/wolfsavard/4716421032@qcoding

http://www.flickr.com/photos/raider3_anime/4566657653

It’s Fun!!

@qcoding

HOW TO GET STARTED

@qcoding

http://www.flickr.com/photos/genista/263235979

TDD Code Katas

@qcoding

• FizzBuzz• Bowling Game• Roman Numerals• More: codingdojo.org/kata

TDD “PAINT BY NUMBERS”• Clojure• C++• C#• Java• JavaScript• Objective-C• Swift

https://www.pinterest.com/source/freekidscoloringandcrafts.com@qcoding

https://github.com/jlangr/name-normalizer

What About Legacy Code?

http://www.columbia.edu/cu/computinghistory/@qcoding

Slides and show notes:qualitycoding.org/talk/svelc2018

Thank you!