SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Overcoming the Obstacles,
Pitfalls, and Dangers of
Automated Testing

      Stephen D. Ritchie
      6-Sept-2012
Purpose




               Useful

          Automated Testing

   Make Software Better
                Excella Consulting
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   -3-
Chrysler New Yorker




                      Excella Consulting
First Topic: Motivation




                    Why Write
                    Unit Tests?
             Why Automate
               Testing?
                          Excella Consulting
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   -6-
Visibility & Insight

Problem Detection

Advance Warning
Microscope: Visibility and Insight




                               Excella Consulting
Smoke Detector: Problem Detection




                           Excella Consulting
Weather Satellite: Advance Warning




                            Excella Consulting
Example




           Perhaps
          An Example
           Would Be
            Helpful

             Excella Consulting
Automated Tests
  Make Sure
Software Works
  As Intended
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   - 13 -
Principles




        Zero Configuration
                  Fast
               Clear Result
             Easy To Maintain
                   Excella Consulting
Automated Testing: Vocabulary




• Test-Driven Development (TDD)
    – Write a Test, Watch the Test Fail
    – Write Code, Make the Test Pass
    – Write the Next Test


• Behavior-Driven Development (BDD)
    – Given a Desired Behavior


• Intention Checking
    – The Software Works, As Intended




                                 Excella Consulting
Principles




        Zero Configuration

 I can run your tests,
 You can run mine.

              Excella Consulting
Principles




             Fast

    All the tests run in
    just a few minutes

             Excella Consulting
Principles




             Clear Results

              Pass/Fail
             Focused Test

                 Excella Consulting
Principles




             Easy to Maintain

             Conventional
                  Brief

                  Excella Consulting
The Long-Term Goals




• Automated Testing
    – Vigilantly Monitoring the Code
• Readability
    – Have Mercy on Future Developers
        • Conventional
        • Short, Clear
• Maintainability
    – Both a Sword and a Shield
        • Code Works as Intended
        • Protects Against Regression
    – Reliable
    – N+1 is Easy




                                 Excella Consulting
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   - 21 -
One Primary Assert To Rule Them All




                   Obstacle 1
        Over-Specifying



                            Excella Consulting
One Primary Assert To Rule Them All




• Is your effort to refactor and improve code overwhelmed by the
  time it takes to maintain/update/rewrite all those failing unit tests?
    – Your test-code could be over specifying things.


• Perhaps an example would be helpful …




                               Excella Consulting
One Primary Assert To Rule Them All




• Debate: Only one assertion per test?

• Test Method Tests One and Only One Scenario
    – 1 Primary Assert Verifies and Validates the Scenario


• Secondary Asserts
    – Support Arrangement and Preconditions
    – Support Post-Conditions


• Avoid Asserts that Over Specify
    – Too Literal => Inhibited Refactoring
    – Imagined Benefit => Rigidity



                               Excella Consulting
Four Ways to Fake Time




                  Obstacle 2
             Time Crunch



                         Excella Consulting
Four Ways to Fake Time




• Are your test methods starting to fail because the code-under-test is
  coupled to the system clock?
    – Your code is too dependent on   System.DateTime.Now

• Perhaps an example would be helpful …




                              Excella Consulting
Four Ways to Fake Time




• Things to Watch For
    – Thread Safety
       • public static class SystemDateTime

   – Making Your Privates Public
   // Inject the class dependency on DateTime.Now
   private DateTime? _now;
   public DateTime Now
   {
       get { return _now ?? DateTime.Now; }
       set { _now = value; }
   }



                          Excella Consulting
Database Killed The Integration Test




                   Obstacle 3
                   Database



                             Excella Consulting
Database Killed The Integration Test




• Are your automated integration tests failing because of the data in
  the testing database; the data keeps changing?

• Perhaps an example would be helpful …




                             Excella Consulting
Database Killed The Integration Test




• Automated Testing Persistence
    – NDbUnit
    – SQL Server Express
    – NHibernate


• Surface Testing
    – Data Access Layer: API Surface
    – Liberates Refactoring




                              Excella Consulting
In Test Code, Do Repeat Yourself ... Do Repeat Yourself




         Obstacle 4
     Unhelpful …
        Reuse
        Repetition
        Coupling
                             Excella Consulting
In Test Code, Do Repeat Yourself ... Do Repeat Yourself




• Do you have an explosion of test methods, with the ratio of test
  code to code-under-test that’s way too high?
    – Your test-code is too DRY in some places and …
    – Not DRY enough in all the right places


• Perhaps an example would be helpful …




                              Excella Consulting
In Test Code, Do Repeat Yourself ... Do Repeat Yourself




• Data-Drive Test Cases
    – One Test Method
    – Many Test Scenarios
• Repeat Code in a “TestsContext” Class
    – Sidecar Approach
• Use Helper Classes
    – Extension methods
    – Composition
• Keep Inheritance in Reserve
    – Overall Testing Framework




                             Excella Consulting
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   - 34 -
Of Course It’s Safe … After You




                             Excella Consulting
Further Discussion




            Any questions?

           Any comments?


                     Excella Consulting
Shameless Self Promotion Time!




                            40% off eBook at
                            apress.com

                            Use promo code:
                            LIN340

                            Offer ends 6-Oct-2012




                            Excella Consulting
Contact Me




• Twitter:    @ruthlesshelp

• Email:      stephen.ritchie@excella.com

• Blog:       http://ruthlesslyhelpful.net

• LinkedIn:   http://www.linkedin.com/in/sritchie




                           Excella Consulting
Slides and Examples




• Slideshare: http://www.slideshare.net/ruthlesshelp

• Github:      http://github.com/ruthlesshelp




                           Excella Consulting

Weitere ähnliche Inhalte

Was ist angesagt?

How to Use Innoslate for Beginners
How to Use Innoslate for BeginnersHow to Use Innoslate for Beginners
How to Use Innoslate for BeginnersElizabeth Steiner
 
Part of the DLM story: Get your Database under Source Control - SQL In The City
Part of the DLM story: Get your Database under Source Control - SQL In The City Part of the DLM story: Get your Database under Source Control - SQL In The City
Part of the DLM story: Get your Database under Source Control - SQL In The City Red Gate Software
 
Clean tests
Clean testsClean tests
Clean testsAgileee
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy CodeExcella
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Red Gate Software
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupEyal Golan
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat
 
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
 [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a... [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...DevDay.org
 

Was ist angesagt? (10)

How to Use Innoslate for Beginners
How to Use Innoslate for BeginnersHow to Use Innoslate for Beginners
How to Use Innoslate for Beginners
 
Part of the DLM story: Get your Database under Source Control - SQL In The City
Part of the DLM story: Get your Database under Source Control - SQL In The City Part of the DLM story: Get your Database under Source Control - SQL In The City
Part of the DLM story: Get your Database under Source Control - SQL In The City
 
Sql server infernals
Sql server infernalsSql server infernals
Sql server infernals
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
Clean tests
Clean testsClean tests
Clean tests
 
Working Effectively With Legacy Code
Working Effectively With Legacy CodeWorking Effectively With Legacy Code
Working Effectively With Legacy Code
 
Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014Get Testing with tSQLt - SQL In The City Workshop 2014
Get Testing with tSQLt - SQL In The City Workshop 2014
 
Single Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance MeetupSingle Responsibility Principle @ Clean Code Alliance Meetup
Single Responsibility Principle @ Clean Code Alliance Meetup
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
 
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
 [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a... [DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
[DevDay 2016] Design Pattern at a glance - Speaker: Tuan Do – Scrum Master a...
 

Ähnlich wie Automated Testing: Obstacles, Pitfalls, and Dangers

DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangersDCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangersStephen Ritchie
 
Overcoming the Obstacles, Pitfalls, and Dangers of Unit Testing
Overcoming the Obstacles, Pitfalls, and Dangers of Unit TestingOvercoming the Obstacles, Pitfalls, and Dangers of Unit Testing
Overcoming the Obstacles, Pitfalls, and Dangers of Unit TestingStephen Ritchie
 
Agile Testing Best Practices
Agile Testing Best PracticesAgile Testing Best Practices
Agile Testing Best PracticesStephen Ritchie
 
An Overview of .NET Best Practices
An Overview of .NET Best PracticesAn Overview of .NET Best Practices
An Overview of .NET Best PracticesStephen Ritchie
 
An Overview of .NET Best Practices
An Overview of .NET Best PracticesAn Overview of .NET Best Practices
An Overview of .NET Best PracticesStephen Ritchie
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using AxiomsSQALab
 
Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Raj Indugula
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best PracticesTomaš Maconko
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for TestingSQALab
 
Search Solutions 2015: Towards a new model of search relevance testing
Search Solutions 2015:  Towards a new model of search relevance testingSearch Solutions 2015:  Towards a new model of search relevance testing
Search Solutions 2015: Towards a new model of search relevance testingCharlie Hull
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesIgor Moochnick
 
ACC presentation for QA Club Kiev
ACC presentation for QA Club KievACC presentation for QA Club Kiev
ACC presentation for QA Club KievNikita Knysh
 
STOP! You're Testing Too Much - Shawn Wallace
STOP!  You're Testing Too Much - Shawn WallaceSTOP!  You're Testing Too Much - Shawn Wallace
STOP! You're Testing Too Much - Shawn WallaceQA or the Highway
 
Stop! you're testing too much
Stop!  you're testing too muchStop!  you're testing too much
Stop! you're testing too muchShawn Wallace
 

Ähnlich wie Automated Testing: Obstacles, Pitfalls, and Dangers (20)

DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangersDCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers
 
Overcoming the Obstacles, Pitfalls, and Dangers of Unit Testing
Overcoming the Obstacles, Pitfalls, and Dangers of Unit TestingOvercoming the Obstacles, Pitfalls, and Dangers of Unit Testing
Overcoming the Obstacles, Pitfalls, and Dangers of Unit Testing
 
Agile Testing Best Practices
Agile Testing Best PracticesAgile Testing Best Practices
Agile Testing Best Practices
 
An Overview of .NET Best Practices
An Overview of .NET Best PracticesAn Overview of .NET Best Practices
An Overview of .NET Best Practices
 
An Overview of .NET Best Practices
An Overview of .NET Best PracticesAn Overview of .NET Best Practices
An Overview of .NET Best Practices
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using Axioms
 
Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Dare to Explore: Discover ET!
Dare to Explore: Discover ET!
 
Intro to TDD
Intro to TDDIntro to TDD
Intro to TDD
 
Delhi it professionals
Delhi it professionalsDelhi it professionals
Delhi it professionals
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for Testing
 
Search Solutions 2015: Towards a new model of search relevance testing
Search Solutions 2015:  Towards a new model of search relevance testingSearch Solutions 2015:  Towards a new model of search relevance testing
Search Solutions 2015: Towards a new model of search relevance testing
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
Code review
Code reviewCode review
Code review
 
ACC presentation for QA Club Kiev
ACC presentation for QA Club KievACC presentation for QA Club Kiev
ACC presentation for QA Club Kiev
 
STOP! You're Testing Too Much - Shawn Wallace
STOP!  You're Testing Too Much - Shawn WallaceSTOP!  You're Testing Too Much - Shawn Wallace
STOP! You're Testing Too Much - Shawn Wallace
 
Stop! you're testing too much
Stop!  you're testing too muchStop!  you're testing too much
Stop! you're testing too much
 
Ml2 production
Ml2 productionMl2 production
Ml2 production
 
Code Review
Code ReviewCode Review
Code Review
 

Mehr von Stephen Ritchie

Overview of .NET Best Practices
Overview of .NET Best PracticesOverview of .NET Best Practices
Overview of .NET Best PracticesStephen Ritchie
 
Lightweight Documentation
Lightweight DocumentationLightweight Documentation
Lightweight DocumentationStephen Ritchie
 
Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Stephen Ritchie
 
Continuous Integration - NoVA CodeCamp 2014-10-11
Continuous Integration - NoVA CodeCamp 2014-10-11Continuous Integration - NoVA CodeCamp 2014-10-11
Continuous Integration - NoVA CodeCamp 2014-10-11Stephen Ritchie
 
Lightweight Documentation: An Agile Approach
Lightweight Documentation: An Agile ApproachLightweight Documentation: An Agile Approach
Lightweight Documentation: An Agile ApproachStephen Ritchie
 
Continuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftStephen Ritchie
 
Dc scrum agile_eng_20130923
Dc scrum agile_eng_20130923Dc scrum agile_eng_20130923
Dc scrum agile_eng_20130923Stephen Ritchie
 
Test Driven Development: Blueprint, Toolbox, and Master Craft
Test Driven Development: Blueprint, Toolbox, and Master CraftTest Driven Development: Blueprint, Toolbox, and Master Craft
Test Driven Development: Blueprint, Toolbox, and Master CraftStephen Ritchie
 
Continuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftStephen Ritchie
 
Continuous Integration DCAEC12
Continuous Integration DCAEC12Continuous Integration DCAEC12
Continuous Integration DCAEC12Stephen Ritchie
 
Advanced Code Analysis with .NET
Advanced Code Analysis with .NETAdvanced Code Analysis with .NET
Advanced Code Analysis with .NETStephen Ritchie
 
Advanced Code Analysis In .NET
Advanced Code Analysis In .NETAdvanced Code Analysis In .NET
Advanced Code Analysis In .NETStephen Ritchie
 

Mehr von Stephen Ritchie (13)

Overview of .NET Best Practices
Overview of .NET Best PracticesOverview of .NET Best Practices
Overview of .NET Best Practices
 
Lightweight Documentation
Lightweight DocumentationLightweight Documentation
Lightweight Documentation
 
Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015Agile Engineering Sparker GLASScon 2015
Agile Engineering Sparker GLASScon 2015
 
DevOps Requires Agility
DevOps Requires AgilityDevOps Requires Agility
DevOps Requires Agility
 
Continuous Integration - NoVA CodeCamp 2014-10-11
Continuous Integration - NoVA CodeCamp 2014-10-11Continuous Integration - NoVA CodeCamp 2014-10-11
Continuous Integration - NoVA CodeCamp 2014-10-11
 
Lightweight Documentation: An Agile Approach
Lightweight Documentation: An Agile ApproachLightweight Documentation: An Agile Approach
Lightweight Documentation: An Agile Approach
 
Continuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master Craft
 
Dc scrum agile_eng_20130923
Dc scrum agile_eng_20130923Dc scrum agile_eng_20130923
Dc scrum agile_eng_20130923
 
Test Driven Development: Blueprint, Toolbox, and Master Craft
Test Driven Development: Blueprint, Toolbox, and Master CraftTest Driven Development: Blueprint, Toolbox, and Master Craft
Test Driven Development: Blueprint, Toolbox, and Master Craft
 
Continuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master CraftContinuous Integration: Blueprint, Toolbox, Master Craft
Continuous Integration: Blueprint, Toolbox, Master Craft
 
Continuous Integration DCAEC12
Continuous Integration DCAEC12Continuous Integration DCAEC12
Continuous Integration DCAEC12
 
Advanced Code Analysis with .NET
Advanced Code Analysis with .NETAdvanced Code Analysis with .NET
Advanced Code Analysis with .NET
 
Advanced Code Analysis In .NET
Advanced Code Analysis In .NETAdvanced Code Analysis In .NET
Advanced Code Analysis In .NET
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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 AutomationSafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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 DevelopmentsTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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 FresherRemote DBA Services
 
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...Martijn de Jong
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
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...
 

Automated Testing: Obstacles, Pitfalls, and Dangers

  • 1. Overcoming the Obstacles, Pitfalls, and Dangers of Automated Testing Stephen D. Ritchie 6-Sept-2012
  • 2. Purpose Useful Automated Testing Make Software Better Excella Consulting
  • 3. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting -3-
  • 4. Chrysler New Yorker Excella Consulting
  • 5. First Topic: Motivation Why Write Unit Tests? Why Automate Testing? Excella Consulting
  • 6. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting -6-
  • 7. Visibility & Insight Problem Detection Advance Warning
  • 8. Microscope: Visibility and Insight Excella Consulting
  • 9. Smoke Detector: Problem Detection Excella Consulting
  • 10. Weather Satellite: Advance Warning Excella Consulting
  • 11. Example Perhaps An Example Would Be Helpful Excella Consulting
  • 12. Automated Tests Make Sure Software Works As Intended
  • 13. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 13 -
  • 14. Principles Zero Configuration Fast Clear Result Easy To Maintain Excella Consulting
  • 15. Automated Testing: Vocabulary • Test-Driven Development (TDD) – Write a Test, Watch the Test Fail – Write Code, Make the Test Pass – Write the Next Test • Behavior-Driven Development (BDD) – Given a Desired Behavior • Intention Checking – The Software Works, As Intended Excella Consulting
  • 16. Principles Zero Configuration I can run your tests, You can run mine. Excella Consulting
  • 17. Principles Fast All the tests run in just a few minutes Excella Consulting
  • 18. Principles Clear Results Pass/Fail Focused Test Excella Consulting
  • 19. Principles Easy to Maintain Conventional Brief Excella Consulting
  • 20. The Long-Term Goals • Automated Testing – Vigilantly Monitoring the Code • Readability – Have Mercy on Future Developers • Conventional • Short, Clear • Maintainability – Both a Sword and a Shield • Code Works as Intended • Protects Against Regression – Reliable – N+1 is Easy Excella Consulting
  • 21. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 21 -
  • 22. One Primary Assert To Rule Them All Obstacle 1 Over-Specifying Excella Consulting
  • 23. One Primary Assert To Rule Them All • Is your effort to refactor and improve code overwhelmed by the time it takes to maintain/update/rewrite all those failing unit tests? – Your test-code could be over specifying things. • Perhaps an example would be helpful … Excella Consulting
  • 24. One Primary Assert To Rule Them All • Debate: Only one assertion per test? • Test Method Tests One and Only One Scenario – 1 Primary Assert Verifies and Validates the Scenario • Secondary Asserts – Support Arrangement and Preconditions – Support Post-Conditions • Avoid Asserts that Over Specify – Too Literal => Inhibited Refactoring – Imagined Benefit => Rigidity Excella Consulting
  • 25. Four Ways to Fake Time Obstacle 2 Time Crunch Excella Consulting
  • 26. Four Ways to Fake Time • Are your test methods starting to fail because the code-under-test is coupled to the system clock? – Your code is too dependent on System.DateTime.Now • Perhaps an example would be helpful … Excella Consulting
  • 27. Four Ways to Fake Time • Things to Watch For – Thread Safety • public static class SystemDateTime – Making Your Privates Public // Inject the class dependency on DateTime.Now private DateTime? _now; public DateTime Now { get { return _now ?? DateTime.Now; } set { _now = value; } } Excella Consulting
  • 28. Database Killed The Integration Test Obstacle 3 Database Excella Consulting
  • 29. Database Killed The Integration Test • Are your automated integration tests failing because of the data in the testing database; the data keeps changing? • Perhaps an example would be helpful … Excella Consulting
  • 30. Database Killed The Integration Test • Automated Testing Persistence – NDbUnit – SQL Server Express – NHibernate • Surface Testing – Data Access Layer: API Surface – Liberates Refactoring Excella Consulting
  • 31. In Test Code, Do Repeat Yourself ... Do Repeat Yourself Obstacle 4 Unhelpful … Reuse Repetition Coupling Excella Consulting
  • 32. In Test Code, Do Repeat Yourself ... Do Repeat Yourself • Do you have an explosion of test methods, with the ratio of test code to code-under-test that’s way too high? – Your test-code is too DRY in some places and … – Not DRY enough in all the right places • Perhaps an example would be helpful … Excella Consulting
  • 33. In Test Code, Do Repeat Yourself ... Do Repeat Yourself • Data-Drive Test Cases – One Test Method – Many Test Scenarios • Repeat Code in a “TestsContext” Class – Sidecar Approach • Use Helper Classes – Extension methods – Composition • Keep Inheritance in Reserve – Overall Testing Framework Excella Consulting
  • 34. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 34 -
  • 35. Of Course It’s Safe … After You Excella Consulting
  • 36. Further Discussion Any questions? Any comments? Excella Consulting
  • 37. Shameless Self Promotion Time! 40% off eBook at apress.com Use promo code: LIN340 Offer ends 6-Oct-2012 Excella Consulting
  • 38. Contact Me • Twitter: @ruthlesshelp • Email: stephen.ritchie@excella.com • Blog: http://ruthlesslyhelpful.net • LinkedIn: http://www.linkedin.com/in/sritchie Excella Consulting
  • 39. Slides and Examples • Slideshare: http://www.slideshare.net/ruthlesshelp • Github: http://github.com/ruthlesshelp Excella Consulting