SlideShare a Scribd company logo
1 of 89
Download to read offline
You need
         some tests yo!




Dave Bouwman // CTO // DTSAgile
the ā€œbigā€ ideas
prove
 code
    works
prove
design
    works
catch
  regression
unit testing
      101
Instantiate class under testā€¦

           Call Methodā€¦

          Check Resultsā€¦

           Call Methodā€¦

          Check Resultsā€¦
good tests areā€¦
      independent
        repeatable
            self-contained*
                professional
good tests areā€¦

      focused
tools!
ā€œunit testing
                           on crackā€
Scott Hanselman
www.hanselman.com
writing
   tests
simple methods
   with simple signatures



   mean simple tests
complex methods
with complex signatures
   meanā€¦
        complex tests
most
 ArcObjects
  applications
 fall in this
    category
for testing
 design we must
separation
   of concerns
a class has
   single
         purpose
stay
  inside
   its
         box
user interface
  (events + logic + data access)
private void ButtonOn_Click(){

    //read values from controls
    //apply business logic
    //connect to database
    //update data
    //update interface

}
user interface
 objects
business
 objects

data access
 objects
Private void ButtonOn_Click(){

    //read values from controls
    //apply business logic
    //send changes to DAL
    //connect to database
    //update data
    //update interface

}
n-tier
 architecture
user interface   WPF/Silverlight
 objects
business
 objects
                 unit
                   tests
data access
 objects
design
patterns yo
model
 view
 controller
ASP.NET MVC
released!!



        http://asp.net/mvc
dependency
management
dependencies
1
    created
    by the
      constructor
private IAccountRepository _accountRepository;
private IFormsAuthentication _formsAuthentication;
private ILogService _logger;

public AccountController()
{
   _accountRepository =
       new AccountRepository(_connectionString);
   _logger = new Logger();
   _formsAuthentication = new FormsAuthentication();
}
what about
   testing
good tests areā€¦
      independent
        repeatable
            self-contained*
                professional
ā€œtight couplingā€



                   external
              dependencies
                     in the
                   tests
internal
dependencies
and
 separate
       them
2   pass
     dependencies
      into the
       constructor
dependency
   injection
private IAccountRepository _accountRepository;
private IFormsAuthentication _formsAuthentication;
private ILogService _logger;

public AccountController(IAccountRepository accountRepository,
         IFormsAuthentication formsAuthentication,
         ILogService logger)
{
   _accountRepository = accountRepository;
   _formsAuthentication = formsAuthentication;
   _logger = logger;
}
pushed
 the
 problem
   up a
     level
inversion
   of control
I need an
AccountController!




                     configuration
                     Global.asax.cs
Castle Windsor
                 Spring.NET
mvccontrib IoC
                 StructureMap

                 Unity




                          http://mvccontrib.codeplex.com
back to
unit testingā€¦
isolated
 testing
&
mock
 fakes
   stubs
code you
 wrote     generated
            on-the-fly
fake
 objects
stub/mock
objects
tools!
rhinomocks




             http://ayende.com/projects/rhino-mocks.aspx
ArcMap
 development
not
  our
 box
separate
      logic
       from
           wiring
emulate
  events
fromArcMap
my code
  sinksā€¦
in
ArcMap
                               Business
          IEditEvents   Shim
                                Logic


     ArcMap
under
  test
                Business
         Test
                 Logic
test
 your
    code

           not
           ESRIā€™s
ArcEngine
Applications
itā€™s
   our
  box
design
 matters.
ArcGIS
 Server
testing
 Web ADFā€¦
custom
services
COM
Utilities
                             SOC

                                   COM
                                   Utility




            WebService



                         ArcGIS Server
Server
 Object
 Extensions                    SOC

                                     SOE




              WebService



                           ArcGIS Server
testable
 classes
   IServerObjectExtension




       COM                      COM
       SOE
      Utility                  Utility
   (ArcObjects)             (ArcObjects)
but iā€™m too
 cool for COMā€¦
jsunit

D.O.H. Unit Testing

FlexUnit

Silverlight Harness
http://mbunit.com

            http://testdriven.net

resources   http://ASP.NET/mvc

            http://mvccontrib.codeplex.com

            http://castleproject.org

            http://ayende.com/projects/rhino-mocks.aspx
iā€™m in teh codez
writin teztz!
and nao u
      can too!
http://blog.davebouwman.net
            dbouwman@dtsagile.com
questions
            http://twitter.com/dbouwman
            http://slideshare.com/dbouwman

More Related Content

What's hot

Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
Joe Wilson
Ā 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Jacinto Limjap
Ā 
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real WorldBenefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Dror Helper
Ā 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing Guidelines
Joel Hooks
Ā 

What's hot (20)

Unit Testing
Unit TestingUnit Testing
Unit Testing
Ā 
Best practices unit testing
Best practices unit testing Best practices unit testing
Best practices unit testing
Ā 
An Introduction to Unit Testing
An Introduction to Unit TestingAn Introduction to Unit Testing
An Introduction to Unit Testing
Ā 
Software Quality via Unit Testing
Software Quality via Unit TestingSoftware Quality via Unit Testing
Software Quality via Unit Testing
Ā 
Unit Testing Done Right
Unit Testing Done RightUnit Testing Done Right
Unit Testing Done Right
Ā 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
Ā 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
Ā 
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Unit testing, UI testing and Test Driven Development in Visual Studio 2012
Ā 
Unit testing
Unit testing Unit testing
Unit testing
Ā 
Unit test
Unit testUnit test
Unit test
Ā 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
Ā 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
Ā 
Benefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real WorldBenefit From Unit Testing In The Real World
Benefit From Unit Testing In The Real World
Ā 
Unit test
Unit testUnit test
Unit test
Ā 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
Ā 
Unit Testing Guidelines
Unit Testing GuidelinesUnit Testing Guidelines
Unit Testing Guidelines
Ā 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Ā 
Unit Test + Functional Programming = Love
Unit Test + Functional Programming = LoveUnit Test + Functional Programming = Love
Unit Test + Functional Programming = Love
Ā 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
Ā 
Unit testing - the hard parts
Unit testing - the hard partsUnit testing - the hard parts
Unit testing - the hard parts
Ā 

Viewers also liked

Viewers also liked (6)

Communication Unit Introduction
Communication Unit IntroductionCommunication Unit Introduction
Communication Unit Introduction
Ā 
Scotland's Listed Buildings and Intervention by Planning Authorities
Scotland's Listed Buildings and Intervention by Planning AuthoritiesScotland's Listed Buildings and Intervention by Planning Authorities
Scotland's Listed Buildings and Intervention by Planning Authorities
Ā 
Foundations
FoundationsFoundations
Foundations
Ā 
Principles of building construction, information and communication
Principles of building construction, information and communicationPrinciples of building construction, information and communication
Principles of building construction, information and communication
Ā 
Unit 101: Principles of building construction, information and communication
Unit 101: Principles of building construction, information and communicationUnit 101: Principles of building construction, information and communication
Unit 101: Principles of building construction, information and communication
Ā 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
Ā 

Similar to Unit Testing 101

Build Comet applications using Scala, Lift, and <b>jQuery</b>
Build Comet applications using Scala, Lift, and <b>jQuery</b>Build Comet applications using Scala, Lift, and <b>jQuery</b>
Build Comet applications using Scala, Lift, and <b>jQuery</b>
tutorialsruby
Ā 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
tutorialsruby
Ā 

Similar to Unit Testing 101 (20)

Introduction to aop
Introduction to aopIntroduction to aop
Introduction to aop
Ā 
Coding Naked
Coding NakedCoding Naked
Coding Naked
Ā 
RESTful apps and services with ASP.NET MVC
RESTful apps and services with ASP.NET MVCRESTful apps and services with ASP.NET MVC
RESTful apps and services with ASP.NET MVC
Ā 
Esri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc FinalEsri Dev Summit 2009 Rest and Mvc Final
Esri Dev Summit 2009 Rest and Mvc Final
Ā 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
Ā 
Highload JavaScript Framework without Inheritance
Highload JavaScript Framework without InheritanceHighload JavaScript Framework without Inheritance
Highload JavaScript Framework without Inheritance
Ā 
Javascript-heavy Salesforce Applications
Javascript-heavy Salesforce ApplicationsJavascript-heavy Salesforce Applications
Javascript-heavy Salesforce Applications
Ā 
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Containerisation Hack of a Legacy Software Solution - Alex Carter - CodeMill ...
Ā 
AWS FIS ć®å®ŸéØ“ćƒ†ćƒ³ćƒ—ćƒ¬ćƒ¼ćƒˆć‚’ę›ø恄恦ćæ悈恆!!
AWS FIS ć®å®ŸéØ“ćƒ†ćƒ³ćƒ—ćƒ¬ćƒ¼ćƒˆć‚’ę›ø恄恦ćæ悈恆!!AWS FIS ć®å®ŸéØ“ćƒ†ćƒ³ćƒ—ćƒ¬ćƒ¼ćƒˆć‚’ę›ø恄恦ćæ悈恆!!
AWS FIS ć®å®ŸéØ“ćƒ†ćƒ³ćƒ—ćƒ¬ćƒ¼ćƒˆć‚’ę›ø恄恦ćæ悈恆!!
Ā 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
Ā 
JSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph PicklJSUG - Filthy Flex by Christoph Pickl
JSUG - Filthy Flex by Christoph Pickl
Ā 
Modular Web Applications With Netzke
Modular Web Applications With NetzkeModular Web Applications With Netzke
Modular Web Applications With Netzke
Ā 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
Ā 
ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017
Ā 
Build Comet applications using Scala, Lift, and <b>jQuery</b>
Build Comet applications using Scala, Lift, and <b>jQuery</b>Build Comet applications using Scala, Lift, and <b>jQuery</b>
Build Comet applications using Scala, Lift, and <b>jQuery</b>
Ā 
<img src="../i/r_14.png" />
<img src="../i/r_14.png" /><img src="../i/r_14.png" />
<img src="../i/r_14.png" />
Ā 
Serverless in production (O'Reilly Software Architecture)
Serverless in production (O'Reilly Software Architecture)Serverless in production (O'Reilly Software Architecture)
Serverless in production (O'Reilly Software Architecture)
Ā 
Divide and Conquer ā€“ Microservices with Node.js
Divide and Conquer ā€“ Microservices with Node.jsDivide and Conquer ā€“ Microservices with Node.js
Divide and Conquer ā€“ Microservices with Node.js
Ā 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
Ā 
Intro to Eclipse Che, by Tyler Jewell
Intro to Eclipse Che, by Tyler JewellIntro to Eclipse Che, by Tyler Jewell
Intro to Eclipse Che, by Tyler Jewell
Ā 

More from Dave Bouwman

Using ArcGIS Server in EC
Using ArcGIS Server in ECUsing ArcGIS Server in EC
Using ArcGIS Server in EC
Dave Bouwman
Ā 
Usability in the GeoWeb
Usability in the GeoWebUsability in the GeoWeb
Usability in the GeoWeb
Dave Bouwman
Ā 

More from Dave Bouwman (13)

HTML5: Not Just for Breakfast
HTML5: Not Just for BreakfastHTML5: Not Just for Breakfast
HTML5: Not Just for Breakfast
Ā 
Client-Side Raster Modeling with PixelBender
Client-Side Raster Modeling with PixelBenderClient-Side Raster Modeling with PixelBender
Client-Side Raster Modeling with PixelBender
Ā 
Vector Tile Caching: ArcStache
Vector Tile Caching: ArcStacheVector Tile Caching: ArcStache
Vector Tile Caching: ArcStache
Ā 
ArcGIS Server in EC2
ArcGIS Server in EC2ArcGIS Server in EC2
ArcGIS Server in EC2
Ā 
Using ArcGIS Server in EC
Using ArcGIS Server in ECUsing ArcGIS Server in EC
Using ArcGIS Server in EC
Ā 
Using ArcGIS Server in EC2
Using ArcGIS Server in EC2Using ArcGIS Server in EC2
Using ArcGIS Server in EC2
Ā 
Building Secure Systems with ArcGIS Server
Building Secure Systems with ArcGIS ServerBuilding Secure Systems with ArcGIS Server
Building Secure Systems with ArcGIS Server
Ā 
Using ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on RailsUsing ArcGIS Server with Ruby on Rails
Using ArcGIS Server with Ruby on Rails
Ā 
Usability in Emergency Response Applications
Usability in Emergency Response ApplicationsUsability in Emergency Response Applications
Usability in Emergency Response Applications
Ā 
Developing for the GeoWeb: Notes From The Field Dev Summit 2009
Developing for the GeoWeb: Notes From The Field Dev Summit 2009Developing for the GeoWeb: Notes From The Field Dev Summit 2009
Developing for the GeoWeb: Notes From The Field Dev Summit 2009
Ā 
Using Virtual Earth to Visualize Fire Risk (Sept 2008)
Using Virtual Earth to Visualize Fire Risk (Sept 2008)Using Virtual Earth to Visualize Fire Risk (Sept 2008)
Using Virtual Earth to Visualize Fire Risk (Sept 2008)
Ā 
Rocky Mountain URISA Talk (June 2008)
Rocky Mountain URISA Talk (June 2008)Rocky Mountain URISA Talk (June 2008)
Rocky Mountain URISA Talk (June 2008)
Ā 
Usability in the GeoWeb
Usability in the GeoWebUsability in the GeoWeb
Usability in the GeoWeb
Ā 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(ā˜Žļø+971_581248768%)**%*]'#abortion pills for sale in dubai@
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
Ā 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Ā 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Ā 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
Ā 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Ā 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Ā 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Ā 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Ā 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
Ā 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
Ā 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
Ā 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Ā 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Ā 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Ā 
Scaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organizationScaling API-first ā€“ The story of a global engineering organization
Scaling API-first ā€“ The story of a global engineering organization
Ā 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Ā 

Unit Testing 101