SlideShare una empresa de Scribd logo
1 de 24
Intro to Test Driven Development (TDD) 
Consulting/Training
Consulting/Training 
About Me 
 Microsoft Client Development MVP 
 ASPInsider 
 Twitter: @joelcochran 
 Email: joelcochran@gmail.com 
 Blog: joelcochran.com 
 Lead Developer, WintellectNOW
Consulting/Training 
About Wintellect 
Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops 
to help our customers achieve their goals through advanced software-based consulting and training solutions. 
consulting 
Wintellect helps you build better software, faster, 
tackling the tough projects and solving the software 
and technology questions that help you transform 
your business. 
 Architecture, Analysis and Design 
 Full lifecycle software development 
 Debugging and Performance tuning 
 Database design and development 
training 
Wintellect's courses are written and taught by some of 
the biggest and most respected names in the Microsoft 
programming industry. 
 Learn from the best. Access the same training 
Microsoft’s developers enjoy 
 Real world knowledge and solutions on both current 
and cutting edge technologies 
 Flexibility in training options – onsite, virtual, on 
demand 
who we are
Wintellect’s On-Demand Video Training Solution 
Try it free 
Code: <INSERT CODE HERE> WintellectNOW.com 
COCHRAN-13 
Authors Enjoy: 
 Royalty Income 
 Personal Branding 
 Cross-Sell Opps 
 Free library access 
Subscribers Enjoy: 
 Expert Instructors 
 Quality Content 
 Practical Application 
 All Devices 
Consulting/Training Individuals | Businesses | Enterprise Organizations
Interview with a Method 
Consulting/Training
The Multiply Method Signature 
Int32 Multiply(Int32[] values) 
Consulting/Training
Consulting/Training 
Question #1 
What parameter(s) do you take? 
An Array of Int32
Consulting/Training 
Question #2 
What value type do you return? 
Int32
Consulting/Training 
Question #3 
What happens when I pass you: 
[3, 4]? 
I don’t know
Consulting/Training 
Question #4 
What happens when I pass you: 
[7]? 
I don’t know
Consulting/Training 
Question #5 
What happens when I pass you: 
[-5, 12, 10, -3]? 
I don’t know
Consulting/Training 
Question #6 
What happens when I pass you: 
null? 
I don’t know
Consulting/Training 
Question #7 
What happens when I pass you: 
[23, Int32.MaxValue]? 
I don’t know
Consulting/Training 
Question #8 
You don’t seem to know much… 
If you don’t know the answer to these 
questions, who does? 
The Unit Tests
Consulting/Training 
What is a Unit Test? 
 Code that tests code 
 Small discrete chunks (units) 
 One test, one condition 
 Based on assumptions 
 Should be automated and repeatable
What a Unit Test is Not 
Consulting/Training 
 An end-to-end test 
 Connected to live data 
 Performing external functions (like sending an Email) 
 User tests
Consulting/Training 
Why write Unit Tests? 
 Test code to ensure proper functionality given certain assumptions 
 Exercise code without running the app 
 Write once, run a million times 
 Guards against unintended consequences 
 Tests define success
Consulting/Training 
What is TDD? 
 Unit Tests are written before the code 
 Helps shape the code to the task at hand 
 Provides focus (YAGNI) 
 The test defines success 
 Run all tests every time
Consulting/Training 
TDD Pattern 
RED 
write a failing test 
GREEN 
write enough code 
to pass 
REFACTOR 
engineer the code
Anatomy of a Unit Test 
Consulting/Training 
Arrange 
• Assumptions 
• Expectations 
Act 
• Execute 
• Results 
Assert 
• Compare 
• Report
Consulting/Training 
TDD Kata 
 Daily exercise – 30 minutes or less 
 Roy Osherove, author of “The Art of Unit Testing”, Manning 
Publications 
 http://osherove.com/tdd-kata-1/ 
 Let’s code!
The String Calculator Kata 
Consulting/Training
Consulting/Training 
StringCalculator Kata
Consulting/Training 
Questions? 
joelcochran@gmail.com

Más contenido relacionado

La actualidad más candente

Mca5020 advanced software engineering-de
Mca5020   advanced software engineering-deMca5020   advanced software engineering-de
Mca5020 advanced software engineering-de
smumbahelp
 
2013 09-11 java zone - extreme programming live
2013 09-11 java zone - extreme programming live2013 09-11 java zone - extreme programming live
2013 09-11 java zone - extreme programming live
Johannes Brodwall
 
Agile and ATDD the perfect couple
Agile and ATDD the perfect coupleAgile and ATDD the perfect couple
Agile and ATDD the perfect couple
Stephen Tucker
 
Test driven developement
Test driven developementTest driven developement
Test driven developement
Bhavik Panchal
 

La actualidad más candente (20)

Mca5020 advanced software engineering-de
Mca5020   advanced software engineering-deMca5020   advanced software engineering-de
Mca5020 advanced software engineering-de
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Programming interview preparation
Programming interview preparationProgramming interview preparation
Programming interview preparation
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
 
2013 09-11 java zone - extreme programming live
2013 09-11 java zone - extreme programming live2013 09-11 java zone - extreme programming live
2013 09-11 java zone - extreme programming live
 
Agile Testing 20021015
Agile Testing 20021015Agile Testing 20021015
Agile Testing 20021015
 
Should you be your own judge?
Should you be your own judge?Should you be your own judge?
Should you be your own judge?
 
Level Up Your Automated Tests
Level Up Your Automated TestsLevel Up Your Automated Tests
Level Up Your Automated Tests
 
(A)TDD The what, why and how
(A)TDD The what, why and how(A)TDD The what, why and how
(A)TDD The what, why and how
 
Introduction to Test Driven Development
Introduction to Test Driven DevelopmentIntroduction to Test Driven Development
Introduction to Test Driven Development
 
Agile and ATDD the perfect couple
Agile and ATDD the perfect coupleAgile and ATDD the perfect couple
Agile and ATDD the perfect couple
 
TDD talk
TDD talkTDD talk
TDD talk
 
Test driven developement
Test driven developementTest driven developement
Test driven developement
 
Refactoring legacy code
Refactoring legacy codeRefactoring legacy code
Refactoring legacy code
 
Pair programming and introduction to TDD
Pair programming and introduction to TDDPair programming and introduction to TDD
Pair programming and introduction to TDD
 
Design talk
Design talkDesign talk
Design talk
 
TDD and more than 9000 tries to sell it to a customer
TDD and more than 9000 tries to sell it to a customerTDD and more than 9000 tries to sell it to a customer
TDD and more than 9000 tries to sell it to a customer
 
Istqb foundation level
Istqb foundation levelIstqb foundation level
Istqb foundation level
 
Stop fearing legacy code
Stop fearing legacy codeStop fearing legacy code
Stop fearing legacy code
 
Xtreme Programming
Xtreme ProgrammingXtreme Programming
Xtreme Programming
 

Destacado

Software project management
Software project managementSoftware project management
Software project management
Saumya Sahu
 
Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
gavhays
 

Destacado (18)

Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2Software Testing and Quality Assurance Assignment 2
Software Testing and Quality Assurance Assignment 2
 
Seeking Assignments in QA/QC , Project Site , Piping Welding/Fabrication , In...
Seeking Assignments in QA/QC , Project Site , Piping Welding/Fabrication , In...Seeking Assignments in QA/QC , Project Site , Piping Welding/Fabrication , In...
Seeking Assignments in QA/QC , Project Site , Piping Welding/Fabrication , In...
 
Software Testing and Quality Assurance Assignment 3
Software Testing and Quality Assurance Assignment 3Software Testing and Quality Assurance Assignment 3
Software Testing and Quality Assurance Assignment 3
 
Software Testing Interview Q&A – part 1
Software Testing Interview Q&A – part 1Software Testing Interview Q&A – part 1
Software Testing Interview Q&A – part 1
 
Multiplateform testing
Multiplateform testingMultiplateform testing
Multiplateform testing
 
Fundamentals of Testing 2
Fundamentals of Testing 2Fundamentals of Testing 2
Fundamentals of Testing 2
 
Software project management
Software project managementSoftware project management
Software project management
 
Some Commonly Asked Question For Software Testing
Some Commonly Asked Question For Software TestingSome Commonly Asked Question For Software Testing
Some Commonly Asked Question For Software Testing
 
Fresher interview question for software testing (QA) manual + basic automation
Fresher interview question for software testing (QA) manual + basic automationFresher interview question for software testing (QA) manual + basic automation
Fresher interview question for software testing (QA) manual + basic automation
 
Testing Software Solutions
Testing Software SolutionsTesting Software Solutions
Testing Software Solutions
 
Manual Testing.
Manual Testing.Manual Testing.
Manual Testing.
 
Gosecure Software Testing
Gosecure Software TestingGosecure Software Testing
Gosecure Software Testing
 
Software testing - basics
Software testing - basicsSoftware testing - basics
Software testing - basics
 
Software testing quiz questions and answers
Software testing quiz questions and answersSoftware testing quiz questions and answers
Software testing quiz questions and answers
 
ISTQB Foundation level Sample Paper - Part 3
ISTQB Foundation level Sample Paper - Part 3 ISTQB Foundation level Sample Paper - Part 3
ISTQB Foundation level Sample Paper - Part 3
 
Software engineering-quiz
Software engineering-quizSoftware engineering-quiz
Software engineering-quiz
 
Software Requirement Specification
Software Requirement SpecificationSoftware Requirement Specification
Software Requirement Specification
 
Software testing objective_types
Software testing objective_typesSoftware testing objective_types
Software testing objective_types
 

Similar a Intro to Unit Testing with test Driven Development

Bcc exceed ste_cert
Bcc exceed ste_certBcc exceed ste_cert
Bcc exceed ste_cert
Susan L.
 
This isn't what you think it is
This isn't what you think it isThis isn't what you think it is
This isn't what you think it is
Joel Cochran
 
Full Stack Software Development
Full Stack Software DevelopmentFull Stack Software Development
Full Stack Software Development
Learnbay
 
Tom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software DevelopmentTom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software Development
Davinci software
 
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project SuccessfulCETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
Chicago eLearning & Technology Showcase
 
How agile is your team
How agile is your teamHow agile is your team
How agile is your team
Phani Bhushan
 

Similar a Intro to Unit Testing with test Driven Development (20)

Fakes
FakesFakes
Fakes
 
Bcc exceed ste_cert
Bcc exceed ste_certBcc exceed ste_cert
Bcc exceed ste_cert
 
This isn't what you think it is
This isn't what you think it isThis isn't what you think it is
This isn't what you think it is
 
StarCanada_EB-Final
StarCanada_EB-FinalStarCanada_EB-Final
StarCanada_EB-Final
 
TDD in Agile
TDD in AgileTDD in Agile
TDD in Agile
 
Automated Unit Testing and TDD
Automated Unit Testing and TDDAutomated Unit Testing and TDD
Automated Unit Testing and TDD
 
Skilling Entry Level Engineers in IoT - A Practical Approach
Skilling Entry Level Engineers in IoT - A Practical ApproachSkilling Entry Level Engineers in IoT - A Practical Approach
Skilling Entry Level Engineers in IoT - A Practical Approach
 
Full Stack Software Development
Full Stack Software DevelopmentFull Stack Software Development
Full Stack Software Development
 
Continuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software WestContinuous Deployment and Testing Workshop from Better Software West
Continuous Deployment and Testing Workshop from Better Software West
 
Agile testing
Agile testingAgile testing
Agile testing
 
Agile Methodologies And Extreme Programming
Agile Methodologies And Extreme ProgrammingAgile Methodologies And Extreme Programming
Agile Methodologies And Extreme Programming
 
Tom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software DevelopmentTom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software Development
 
Developers Nepal Meetup #4 Report
Developers Nepal Meetup #4 ReportDevelopers Nepal Meetup #4 Report
Developers Nepal Meetup #4 Report
 
DevOps Roadtrip Final Speaking Deck
DevOps Roadtrip Final Speaking Deck DevOps Roadtrip Final Speaking Deck
DevOps Roadtrip Final Speaking Deck
 
I Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer UsefulI Don't Code, Am I No Longer Useful
I Don't Code, Am I No Longer Useful
 
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project SuccessfulCETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
CETS 2011, Mark Steiner, Top 10 Ways to Make Your eLearning Project Successful
 
How agile is your team
How agile is your teamHow agile is your team
How agile is your team
 
Career Counseling for Embedded Systems Wannabes
Career Counseling for Embedded Systems WannabesCareer Counseling for Embedded Systems Wannabes
Career Counseling for Embedded Systems Wannabes
 
Microsoft SQL Server Training, ASP.NET Training, SQL Server, .NET 4.0 - Syner...
Microsoft SQL Server Training, ASP.NET Training, SQL Server, .NET 4.0 - Syner...Microsoft SQL Server Training, ASP.NET Training, SQL Server, .NET 4.0 - Syner...
Microsoft SQL Server Training, ASP.NET Training, SQL Server, .NET 4.0 - Syner...
 
Quality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the RoomQuality Metrics: The Dirty Word in the Room
Quality Metrics: The Dirty Word in the Room
 

Último

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Intro to Unit Testing with test Driven Development

  • 1. Intro to Test Driven Development (TDD) Consulting/Training
  • 2. Consulting/Training About Me  Microsoft Client Development MVP  ASPInsider  Twitter: @joelcochran  Email: joelcochran@gmail.com  Blog: joelcochran.com  Lead Developer, WintellectNOW
  • 3. Consulting/Training About Wintellect Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions. consulting Wintellect helps you build better software, faster, tackling the tough projects and solving the software and technology questions that help you transform your business.  Architecture, Analysis and Design  Full lifecycle software development  Debugging and Performance tuning  Database design and development training Wintellect's courses are written and taught by some of the biggest and most respected names in the Microsoft programming industry.  Learn from the best. Access the same training Microsoft’s developers enjoy  Real world knowledge and solutions on both current and cutting edge technologies  Flexibility in training options – onsite, virtual, on demand who we are
  • 4. Wintellect’s On-Demand Video Training Solution Try it free Code: <INSERT CODE HERE> WintellectNOW.com COCHRAN-13 Authors Enjoy:  Royalty Income  Personal Branding  Cross-Sell Opps  Free library access Subscribers Enjoy:  Expert Instructors  Quality Content  Practical Application  All Devices Consulting/Training Individuals | Businesses | Enterprise Organizations
  • 5. Interview with a Method Consulting/Training
  • 6. The Multiply Method Signature Int32 Multiply(Int32[] values) Consulting/Training
  • 7. Consulting/Training Question #1 What parameter(s) do you take? An Array of Int32
  • 8. Consulting/Training Question #2 What value type do you return? Int32
  • 9. Consulting/Training Question #3 What happens when I pass you: [3, 4]? I don’t know
  • 10. Consulting/Training Question #4 What happens when I pass you: [7]? I don’t know
  • 11. Consulting/Training Question #5 What happens when I pass you: [-5, 12, 10, -3]? I don’t know
  • 12. Consulting/Training Question #6 What happens when I pass you: null? I don’t know
  • 13. Consulting/Training Question #7 What happens when I pass you: [23, Int32.MaxValue]? I don’t know
  • 14. Consulting/Training Question #8 You don’t seem to know much… If you don’t know the answer to these questions, who does? The Unit Tests
  • 15. Consulting/Training What is a Unit Test?  Code that tests code  Small discrete chunks (units)  One test, one condition  Based on assumptions  Should be automated and repeatable
  • 16. What a Unit Test is Not Consulting/Training  An end-to-end test  Connected to live data  Performing external functions (like sending an Email)  User tests
  • 17. Consulting/Training Why write Unit Tests?  Test code to ensure proper functionality given certain assumptions  Exercise code without running the app  Write once, run a million times  Guards against unintended consequences  Tests define success
  • 18. Consulting/Training What is TDD?  Unit Tests are written before the code  Helps shape the code to the task at hand  Provides focus (YAGNI)  The test defines success  Run all tests every time
  • 19. Consulting/Training TDD Pattern RED write a failing test GREEN write enough code to pass REFACTOR engineer the code
  • 20. Anatomy of a Unit Test Consulting/Training Arrange • Assumptions • Expectations Act • Execute • Results Assert • Compare • Report
  • 21. Consulting/Training TDD Kata  Daily exercise – 30 minutes or less  Roy Osherove, author of “The Art of Unit Testing”, Manning Publications  http://osherove.com/tdd-kata-1/  Let’s code!
  • 22. The String Calculator Kata Consulting/Training

Notas del editor

  1. Actual result == Int32.MaxValue – (multiplier – 1) == 2147483625 Int32.MaxValue = 2147483647 Every time you multiply (except for * 1) you overflow the Integer value Subtract 1 for the value of 0 every time this happens