SlideShare uma empresa Scribd logo
1 de 40
http://dc-agile-engineering-conference.eventbrite.com/
Overcoming the Obstacles,
Pitfalls, and Dangers of
Automated Testing

      Stephen D. Ritchie
      16-Oct-2012
Purpose




               Useful

          Automated Testing

   Make Software Better
                Excella Consulting
Agenda
  1   Motivation

  2   Principles

  3   Obstacles
         Excella Consulting   -4-
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   -7-
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   - 14 -
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   - 22 -
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   - 35 -
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:
                            UGoCTNoV

                            Offer ends 10-Nov-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

Mais conteúdo relacionado

Mais procurados

Test Automation Patterns: Issues and Solutions
Test Automation Patterns: Issues and SolutionsTest Automation Patterns: Issues and Solutions
Test Automation Patterns: Issues and SolutionsTechWell
 
RecSys 2016 Talk: Feature Selection For Human Recommenders
RecSys 2016 Talk: Feature Selection For Human RecommendersRecSys 2016 Talk: Feature Selection For Human Recommenders
RecSys 2016 Talk: Feature Selection For Human RecommendersKatherine Livins
 
Common Technical Writing Issues
Common Technical Writing IssuesCommon Technical Writing Issues
Common Technical Writing IssuesTao Xie
 
Starting data science with kaggle.com
Starting data science with kaggle.comStarting data science with kaggle.com
Starting data science with kaggle.comNathaniel Shimoni
 
Lean DevOps - Lessons Learned from Innovation-driven Companies
Lean DevOps - Lessons Learned from Innovation-driven CompaniesLean DevOps - Lessons Learned from Innovation-driven Companies
Lean DevOps - Lessons Learned from Innovation-driven CompaniesXavier Amatriain
 
STARCANADA 2013 Keynote: Lightning Strikes the Keynotes
STARCANADA 2013 Keynote: Lightning Strikes the KeynotesSTARCANADA 2013 Keynote: Lightning Strikes the Keynotes
STARCANADA 2013 Keynote: Lightning Strikes the KeynotesTechWell
 
Testing katas - Try before you buy
Testing katas - Try before you buyTesting katas - Try before you buy
Testing katas - Try before you buyEmma Armstrong
 
Replication of Recommender Systems Research
Replication of Recommender Systems ResearchReplication of Recommender Systems Research
Replication of Recommender Systems ResearchAlan Said
 
Test Design For Everyone
Test Design For EveryoneTest Design For Everyone
Test Design For EveryoneAlan Page
 
How to prepare for ieee se certifications
How to prepare for ieee se certificationsHow to prepare for ieee se certifications
How to prepare for ieee se certificationsGanesh Samarthyam
 
How Technology Can Help Students Improving their Performance in competitive e...
How Technology Can Help Students Improving their Performance in competitive e...How Technology Can Help Students Improving their Performance in competitive e...
How Technology Can Help Students Improving their Performance in competitive e...gunjan9um
 

Mais procurados (11)

Test Automation Patterns: Issues and Solutions
Test Automation Patterns: Issues and SolutionsTest Automation Patterns: Issues and Solutions
Test Automation Patterns: Issues and Solutions
 
RecSys 2016 Talk: Feature Selection For Human Recommenders
RecSys 2016 Talk: Feature Selection For Human RecommendersRecSys 2016 Talk: Feature Selection For Human Recommenders
RecSys 2016 Talk: Feature Selection For Human Recommenders
 
Common Technical Writing Issues
Common Technical Writing IssuesCommon Technical Writing Issues
Common Technical Writing Issues
 
Starting data science with kaggle.com
Starting data science with kaggle.comStarting data science with kaggle.com
Starting data science with kaggle.com
 
Lean DevOps - Lessons Learned from Innovation-driven Companies
Lean DevOps - Lessons Learned from Innovation-driven CompaniesLean DevOps - Lessons Learned from Innovation-driven Companies
Lean DevOps - Lessons Learned from Innovation-driven Companies
 
STARCANADA 2013 Keynote: Lightning Strikes the Keynotes
STARCANADA 2013 Keynote: Lightning Strikes the KeynotesSTARCANADA 2013 Keynote: Lightning Strikes the Keynotes
STARCANADA 2013 Keynote: Lightning Strikes the Keynotes
 
Testing katas - Try before you buy
Testing katas - Try before you buyTesting katas - Try before you buy
Testing katas - Try before you buy
 
Replication of Recommender Systems Research
Replication of Recommender Systems ResearchReplication of Recommender Systems Research
Replication of Recommender Systems Research
 
Test Design For Everyone
Test Design For EveryoneTest Design For Everyone
Test Design For Everyone
 
How to prepare for ieee se certifications
How to prepare for ieee se certificationsHow to prepare for ieee se certifications
How to prepare for ieee se certifications
 
How Technology Can Help Students Improving their Performance in competitive e...
How Technology Can Help Students Improving their Performance in competitive e...How Technology Can Help Students Improving their Performance in competitive e...
How Technology Can Help Students Improving their Performance in competitive e...
 

Semelhante a DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers

Automated Testing: Obstacles, Pitfalls, and Dangers
Automated Testing: Obstacles, Pitfalls, and DangersAutomated Testing: Obstacles, Pitfalls, and Dangers
Automated Testing: Obstacles, Pitfalls, and DangersStephen Ritchie
 
Agile Testing Best Practices
Agile Testing Best PracticesAgile Testing Best Practices
Agile Testing Best PracticesStephen Ritchie
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with DatabasesStephen Ritchie
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using AxiomsSQALab
 
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
 
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
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for TestingSQALab
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best PracticesTomaš Maconko
 
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
 
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
 
A New Model For Testing
A New Model For TestingA New Model For Testing
A New Model For TestingTEST Huddle
 
New Model Testing: A New Test Process and Tool
New Model Testing:  A New Test Process and ToolNew Model Testing:  A New Test Process and Tool
New Model Testing: A New Test Process and ToolTEST Huddle
 
Clean tests
Clean testsClean tests
Clean testsAgileee
 

Semelhante a DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers (20)

Automated Testing: Obstacles, Pitfalls, and Dangers
Automated Testing: Obstacles, Pitfalls, and DangersAutomated Testing: Obstacles, Pitfalls, and Dangers
Automated Testing: Obstacles, Pitfalls, and Dangers
 
Agile Testing Best Practices
Agile Testing Best PracticesAgile Testing Best Practices
Agile Testing Best Practices
 
Automated Testing with Databases
Automated Testing with DatabasesAutomated Testing with Databases
Automated Testing with Databases
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using Axioms
 
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
 
Delhi it professionals
Delhi it professionalsDelhi it professionals
Delhi it professionals
 
Dare to Explore: Discover ET!
Dare to Explore: Discover ET!Dare to Explore: Discover ET!
Dare to Explore: Discover ET!
 
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
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for Testing
 
Unit Testing Best Practices
Unit Testing Best PracticesUnit Testing Best Practices
Unit Testing Best Practices
 
Arch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best PracticesArch factory - Agile Design: Best Practices
Arch factory - Agile Design: Best Practices
 
ACC presentation for QA Club Kiev
ACC presentation for QA Club KievACC presentation for QA Club Kiev
ACC presentation for QA Club Kiev
 
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
 
New model
New modelNew model
New model
 
A New Model For Testing
A New Model For TestingA New Model For Testing
A New Model For Testing
 
Code review
Code reviewCode review
Code review
 
Ml2 production
Ml2 productionMl2 production
Ml2 production
 
New Model Testing: A New Test Process and Tool
New Model Testing:  A New Test Process and ToolNew Model Testing:  A New Test Process and Tool
New Model Testing: A New Test Process and Tool
 
Clean tests
Clean testsClean tests
Clean tests
 

Mais de 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
 

Mais de 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
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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 organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[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
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
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)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[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
 

DCDNUG 10/16/2012 Automated testing obstacles pitfalls dangers

  • 2. Overcoming the Obstacles, Pitfalls, and Dangers of Automated Testing Stephen D. Ritchie 16-Oct-2012
  • 3. Purpose Useful Automated Testing Make Software Better Excella Consulting
  • 4. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting -4-
  • 5. Chrysler New Yorker Excella Consulting
  • 6. First Topic: Motivation Why Write Unit Tests? Why Automate Testing? Excella Consulting
  • 7. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting -7-
  • 8. Visibility & Insight Problem Detection Advance Warning
  • 9. Microscope: Visibility and Insight Excella Consulting
  • 10. Smoke Detector: Problem Detection Excella Consulting
  • 11. Weather Satellite: Advance Warning Excella Consulting
  • 12. Example Perhaps An Example Would Be Helpful Excella Consulting
  • 13. Automated Tests Make Sure Software Works As Intended
  • 14. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 14 -
  • 15. Principles Zero Configuration Fast Clear Result Easy To Maintain Excella Consulting
  • 16. 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
  • 17. Principles Zero Configuration I can run your tests, You can run mine. Excella Consulting
  • 18. Principles Fast All the tests run in just a few minutes Excella Consulting
  • 19. Principles Clear Results Pass/Fail Focused Test Excella Consulting
  • 20. Principles Easy to Maintain Conventional Brief Excella Consulting
  • 21. 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
  • 22. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 22 -
  • 23. One Primary Assert To Rule Them All Obstacle 1 Over-Specifying Excella Consulting
  • 24. 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
  • 25. 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
  • 26. Four Ways to Fake Time Obstacle 2 Time Crunch Excella Consulting
  • 27. 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
  • 28. 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
  • 29. Database Killed The Integration Test Obstacle 3 Database Excella Consulting
  • 30. 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
  • 31. Database Killed The Integration Test • Automated Testing Persistence – NDbUnit – SQL Server Express – NHibernate • Surface Testing – Data Access Layer: API Surface – Liberates Refactoring Excella Consulting
  • 32. In Test Code, Do Repeat Yourself ... Do Repeat Yourself Obstacle 4 Unhelpful … Reuse Repetition Coupling Excella Consulting
  • 33. 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
  • 34. 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
  • 35. Agenda 1 Motivation 2 Principles 3 Obstacles Excella Consulting - 35 -
  • 36. Of Course It’s Safe … After You Excella Consulting
  • 37. Further Discussion Any questions? Any comments? Excella Consulting
  • 38. Shameless Self Promotion Time! 40% off eBook at apress.com Use promo code: UGoCTNoV Offer ends 10-Nov-2012 Excella Consulting
  • 39. Contact Me • Twitter: @ruthlesshelp • Email: stephen.ritchie@excella.com • Blog: http://ruthlesslyhelpful.net • LinkedIn: http://www.linkedin.com/in/sritchie Excella Consulting
  • 40. Slides and Examples • Slideshare: http://www.slideshare.net/ruthlesshelp • Github: http://github.com/ruthlesshelp Excella Consulting