SlideShare a Scribd company logo
ParasoftCopyright© 2015 1
2015-05-01
Are Your Continuous Tests
Too Fragile for Agile
Arthur Hicken
Parasoft Evangelist
ParasoftCopyright© 2015 22
Arthur Hicken Bio
Arthur “Code Curmudgeon” Hicken is heavily involved in the
development and testing communities. He is passionate about
businesses realizing the full potential of testing solutions. As an
expert in his field, Arthur is a sought after speaker regarding
testing strategies, efficiencies and results.
He has been at Parasoft for over 20 years driving the strategic
conversation around SDLC practices that
enhance productivity and quality. In
addition to holding the title of Evangelist,
Arthur represents Parasoft on multiple
industry organizations including ICSQ,
OWASP, NIST/SAMATE, CWE and more.
ParasoftCopyright© 2015 33
Agenda
 Challenges of Continuous Agile
 Testing defined
 Testing is hard (no one wants to do it)
 Best practices
 A modest proposal: Spring cleaning
ParasoftCopyright© 2015 44
The role of QA in Agile
 QA is part of development, not an
afterthought
 Review developer testing efforts
 Additional testing of requirements
 Iterative during development
 Fast discovery and reporting of defects
 Investigate root cause of defects
 Influence development policy
ParasoftCopyright© 2015 55
Challenges of Agile
 Need to be fast
 Need to be flexible
 Testing can be overlooked if not baked in
 Architectural compromises from schedule
ParasoftCopyright© 2015 66
Challenges of Continuous
 Tests must produce binary decision go/no-go
 Reuse unit test and functional tests from dev
to QA
 High level of automation
 Requires disciplined mature process
 Testing must automatically answer
 Is it stable
 Will it do what it’s supposed to do
ParasoftCopyright© 2015 77
Importance of Testing
How do you know when you're done?
How do you know if a fix for a minor bug broke a major
function of the system?
How can the system evolve into something more than is
currently envisioned?
Testing,both unit and functional,needs to be an
integratedpart of the developmentprocess.
ParasoftCopyright© 2015 88
Testing delivers
A maintained suite of unit tests:
 Represents the most practical design possible
 Provides the best form of documentation for
classes
 Determines when a class is "done"
 Gives a developer confidence in the code
 Is a basis for refactoring quickly
ParasoftCopyright© 2015 99
Why Testing is Often Ignored
• Too much effort
• Too much time
• We’re on a schedule – no time to test.
• Why is there always time to do it over, but never to do it right?
Perceived as “burdensome”
• “I don’t need to test my code – I don’t make mistakes.”
• Testing means I have to admit that I might have made a mistake.
• I don’t like to test – it’s beneath me.
• Testing isn’t fun – I just want to code!
• That’s for the QA dept.
Developer Ego
ParasoftCopyright© 2015 1010
Definitions
 Unit
 Functional
 Regression
ParasoftCopyright© 2015 1111
Unit Testing
Unit tests that validates your method behaves a
certain way given a specific parameters
 Regressions testing
 Validate behavior of existing code hasn’t changed
 Scheduled and run automatically
 Test Driven Development
 Validate behavior of new code to be written
 Created before developing, turned into regression tests
after
ParasoftCopyright© 2015 1212
Functional Testing
• Unit tests (Junit, CppUnit, Nunit, etc)
• Integration tests
• Scripted tests
• Manual tests
Incarnations of functional tests
• Manually written
• Machine generated from application tracing
• Machine generated from capturing traffic
• Machine generated from recording clicks
Ways to createfunctional tests
ParasoftCopyright© 2015 1313
Regression Testing
• Functional unit tests that pass
• Machine generated unit tests for current behavior
• Unit test written by developers and testers
• Tests written to validate bug fixes
Contributors to the regression test suite
• Unwanted change in behavior – fix the code
• Intentional change in specification – update test
controls
Regression test failures
ParasoftCopyright© 2015 1414
What’s the Difference?
Unit Tests
• The code is doing things right
• Written fromprogrammers perspective
• Confirm code gives proper output based on specific input
Functional Tests
• The code is doing the right thing
• Written fromusers perspective
• Confirm the system does what the user expects it to do
Regression Tests
• It still works
ParasoftCopyright© 2015 1515
Why Do Unit Testing
Software bugs are inserted during coding phase, but
often aren’t found until functional testing, or worse
they are found by customers. The longer a bug stays
in the system, the more expensive it is to fix it.
Unit testing is a strategy that allows you to find out if
your system is behaving the way you expect early in
the SDLC.
Unit testing allows for easy regression testing, so you
can find out quickly whether you have introduced
some unexpected behavior into the system.
ParasoftCopyright© 2015 1616
The Cost of Defects
ParasoftCopyright© 2015 1717
Best Practices
ParasoftCopyright© 2015 1818
What’s Important
Unit tests require a LOT of care
Unit testing is a continuous operation
Test suite maintenance is a commitment
Control data (assertions) in the code
ParasoftCopyright© 2015 1919
Test incorporation
 Take existing unit tests and schedule them into
build process
 Run and fix tests as part of build process
 Ideal goal: 0 failures and 100% code coverage
 Realistic goal: 10% test failures and 80% code
coverage
 If the unit test suite is noisy, don’t qualify the
build based on assertion failures
ParasoftCopyright© 2015 2020
Unit Test Creation
 Maintainability
 Proper assertions
 Nightly runs
 Tests should be:
 Automatic (no human input or review)
 Repeatable (no strange dependencies)
ParasoftCopyright© 2015 2121
Legacy Test Suites
 Leverage your existing suite
 Clean up incrementally
 Set policy based on current results
 Tighten policy when in compliance
ParasoftCopyright© 2015 2222
Maintaining and Creating UT
 Maintaining is more of a problem than
creating.
 Don’t create a test if you can’t or don’t plan to
maintain it.
 Creating as you go creates a better test suite
 Tests not run regularly become irrelevant
ParasoftCopyright© 2015 2323
Write tests with the code
Create the test when you’re writing the code
Have a test for every task you complete
Increases understanding
Improve assertions
ParasoftCopyright© 2015 2424
Connect Unit Tests
 Associate tests with Code and Requirements
 Naming Conventions should have meaning
 Use code comment tags @task @pr @fr
 Use check-in comments @task @pr @fr
 Improve change-based testing
ParasoftCopyright© 2015 2525
Specific Generation
 Don’t be lured by 100% coverage
 Auto assertions are not meaningful unless
validated
 Review the tests as you work on the code
ParasoftCopyright© 2015 2626
Code Review Test
 Code for unit tests should be reviewed
 Consider doing test-design review
 Ensures you’re testing what you think you are
 Helps reduce noise
 Helps improve understanding
 Review the code and the test code together
ParasoftCopyright© 2015 2727
Testing Exception Handling
 Frequently Skipped
 Prevents crashes
 Prevents death spiral
 Rule of thirds
 1/3 basic functionality
 1/3 advanced features / infrequent settings
 1/3 error handling
ParasoftCopyright© 2015 2828
All About Assertions
 Verifies that the code behaves as intended
 True/false
 Null or not null
 Specific values
 Complex conditions
ParasoftCopyright© 2015 2929
Why Assert?
 Excuses:
 My code already has
console output
 I can check it
visually/manually
 Binary output (pass/fail)
 Part of overall test suite
 No human intervention
ParasoftCopyright© 2015 3030
Assertion failures
Introduced coding error
• Fix the new code
Functionality changed
• Update the assertion
Improper assertion
• Comment it out
ParasoftCopyright© 2015 3131
Assertion Policy
 Assign failures as tasks
 Author of the test or of the changed code
 Try to reach developer that has the highest chance
to understand the change
 Developer assesses failure:
 Bug (fix)
 Changed functionality (update assertion)
 Bad assertion (improve or remove) - don’t delete;
instead, comment out
ParasoftCopyright© 2015 3232
What to assert
 Ease of creating assertions leads to poor
choices
 Anything CAN be checked – but should it be?
 Assertions should be connected to what
you’re trying to test
 Assertions should be logically invariant
 Check values by range, not equivalence
 “What do I expect here logically?”
ParasoftCopyright© 2015 3333
How to recognize bad assertions
 How often do you WANT to manually verify an
assertion?
 Daily or near-daily checking indicates poor
assertion.
 Troublesome possibilities:
 Date
 User or machine name
 OS
 Filesystem names and paths
ParasoftCopyright© 2015 3434
Missing Assertions
 Error was found after code changed
 Test suite never caught the error
 Update unit-test with new assertion
 Write new unit tests as necessary
ParasoftCopyright© 2015 3535
Cleaning It Up
ParasoftCopyright© 2015 3636
The Challenge: Management’s Perspective
 Need tests to reduce risks
 Testing takes time from
features/fixes
 Not enough time
 Not enough people
 Tests and reports lack context
ParasoftCopyright© 2015 3737
The Challenge: Development’s Perspective
 Hundreds of failing or
broken tests
 Test requirements unclear
 Existing tests are dubious
 Deadline pressure
ParasoftCopyright© 2015 3838
Spring Cleaning Solution
 Throw out the useless, old junk
 Identify and eliminate “noisy” tests
 Organize the remaining chores
 Prioritize unit test tasks
 Keep it clean
 Establish and follow a routine test maintenance plan
ParasoftCopyright© 2015 3939
Throw out the Junk: Identifying Noisy Tests
Tests that are fragile
• Pass/Fail/Incomplete resultsfrequentlychange
• Frequentchangesare requiredto keep up-to-date
Tests that are outdated
• More than“n” releaseshaveoccurred despitethistest failure
• The test appliesto legacy codethat is frozen
• The test hasnot been executedfor “x” periodof time
Tests that are unclear
• It takes more than5 minutesto understand why thetest exists
• The failuremessage is incorrect/unhelpful/irrelevant
• There is no associated requirementordefect
Be merciless!
ParasoftCopyright© 2015 4040
Organize Chores: Prioritize Tasks with Policy
All tasks are created equal
Some tasks are more equal than others
Policies establish prioritization and assignment
ParasoftCopyright© 2015 4141
Keep it Clean: Establish a Routine Process
 Management and Development need to co-define a Policy
 Clear testing goals that tie tests to business needs
 Clear delineation of responsibility
 Test creation and deletion
 Test failureresolution
 Naming conventions
 Peer review
 Clear and frequentcommunication
 Understand the technical and business impact
 Enhance traceability to project requirements
 Ask questions
 Focus on safety/quality, not coverage
 Keep the number of tests minimal
 Run all tests on a regularly scheduled, frequent basis
 Clean as you go
ParasoftCopyright© 2015 4242
Spring Cleaning Recap
 Find and delete “noisy” tests
 Use policies to prioritize, assign, and plan
 Co-design and follow a process to keep it clean
ParasoftCopyright© 2015 4343
 Web
 http://www.parasoft.com/jsp/resources
 Blog
 http://alm.parasoft.com
Social
 Facebook: https://www.facebook.com/parasoftcorporation
 Twitter: @Parasoft@MustRead4Dev @CodeCurmudgeon
 LinkedIn: http://www.linkedin.com/company/parasoft
 Google+: +Parasoft +ArthurHickenCodeCurmudgeon
 Google+ Community: Development Testing Because its Better

More Related Content

PPTX
Continuous Testing in Vegas
PDF
DevOps 2017 Conf: evolving from automated to continuous
PDF
Top Chrome Extensions for Software Testing
PDF
Pairwise testing
PDF
Test Case Prioritization Techniques
PPTX
Test Metrics in Agile - powerful tool to support changes - Zavertailo Iuliia
PDF
A Concise QA Process
PDF
Instill a DevOps Testing Culture in Your Team and Organization
Continuous Testing in Vegas
DevOps 2017 Conf: evolving from automated to continuous
Top Chrome Extensions for Software Testing
Pairwise testing
Test Case Prioritization Techniques
Test Metrics in Agile - powerful tool to support changes - Zavertailo Iuliia
A Concise QA Process
Instill a DevOps Testing Culture in Your Team and Organization

What's hot (20)

PPTX
Agile Test Automation
PDF
5 Steps to Jump Start Your Test Automation
PDF
The Definitive Guide to Implementing Shift Left Testing in QA
PDF
Continuous Deployment and Testing Workshop from Better Software West
PDF
Vladimir Primakov - Qa management in big agile teams
PDF
QA metrics in Agile (GUIDE)
PPT
Test Automation Strategies For Agile
PPTX
SpiraTest: Designing and Creating Test Script
PDF
Appium, Test-Driven Development, and Continuous Integration
PPTX
Testing Best Practices
PPTX
Continuous integration testing fundamentals
PDF
QA Process Overview for Firefox OS 2014
PDF
Fundamentals of testing 1
PDF
Why Automation Fails—in Theory and Practice
PDF
Large-Scale Agile Test Automation Strategies in Practice
PDF
Inverting Test Pyramid - A First Hand Experience Report
PPTX
Test strategicaly
PDF
Applying Agile Principles to Test Automation Development
PDF
Building a Test Automation Strategy for Success
PPTX
The Test Pyramid
Agile Test Automation
5 Steps to Jump Start Your Test Automation
The Definitive Guide to Implementing Shift Left Testing in QA
Continuous Deployment and Testing Workshop from Better Software West
Vladimir Primakov - Qa management in big agile teams
QA metrics in Agile (GUIDE)
Test Automation Strategies For Agile
SpiraTest: Designing and Creating Test Script
Appium, Test-Driven Development, and Continuous Integration
Testing Best Practices
Continuous integration testing fundamentals
QA Process Overview for Firefox OS 2014
Fundamentals of testing 1
Why Automation Fails—in Theory and Practice
Large-Scale Agile Test Automation Strategies in Practice
Inverting Test Pyramid - A First Hand Experience Report
Test strategicaly
Applying Agile Principles to Test Automation Development
Building a Test Automation Strategy for Success
The Test Pyramid
Ad

Similar to Are Your Continuous Tests Too Fragile for Agile? (20)

PDF
Better Software East 2016: Evolving Automated to Continuous
PPTX
Making the Unstable Stable - An Intro To Testing
PDF
An Introduction To Software Development - Final Review
PDF
Workshop unit test
PDF
Are Your Continuous Tests Too Fragile for Agile?
PPTX
TDD Best Practices
PPTX
Why does agile need unit testing
PDF
When the System Creaks: Lessons Learned in Agile Maintenance
PPTX
How to Avoid Continuously Delivering Faulty Software
PDF
The Developer’s Guide to Test Automation
PPTX
Ben Walters - Creating Customer Value With Agile Testing - EuroSTAR 2011
PPTX
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
PDF
Ethan huang 全民qa
PPTX
Development without Testers: Myth or Real Option?
PDF
Introduction to Automated Testing
PDF
Introduction to-automated-testing
PDF
What CS Class Didn't Teach About Testing
PDF
The Testers' Secret Weapon - Code Reviews
PPTX
Testing & should i do it
PDF
Test Automation using UiPath Test Suite - Developer Circle Part-1.pdf
Better Software East 2016: Evolving Automated to Continuous
Making the Unstable Stable - An Intro To Testing
An Introduction To Software Development - Final Review
Workshop unit test
Are Your Continuous Tests Too Fragile for Agile?
TDD Best Practices
Why does agile need unit testing
When the System Creaks: Lessons Learned in Agile Maintenance
How to Avoid Continuously Delivering Faulty Software
The Developer’s Guide to Test Automation
Ben Walters - Creating Customer Value With Agile Testing - EuroSTAR 2011
Development without Testers: Myth or Real Option? (ConfeT&QA conference)
Ethan huang 全民qa
Development without Testers: Myth or Real Option?
Introduction to Automated Testing
Introduction to-automated-testing
What CS Class Didn't Teach About Testing
The Testers' Secret Weapon - Code Reviews
Testing & should i do it
Test Automation using UiPath Test Suite - Developer Circle Part-1.pdf
Ad

More from Parasoft (20)

PDF
Testing a Microservices Architecture
PDF
ABC's of Service Virtualization
PDF
The Legend of Software Hollow: Defeating the Headless Horseman of Faulty Appl...
PDF
AppsSec In a DevOps World
PDF
Driving Risks Out of Embedded Automotive Software
PDF
Rx for FDA Software Compliance
PDF
Software Safety and Security Through Standards
PDF
No Devops Without Continuous Testing
PDF
Accelerate Agile Development with Service Virtualization - Czech Test
PDF
Evolving from Automated to Continous Testing for Agile and DevOps
PDF
Deploy + Destroy Complete Test Environments
PDF
MedicAlert API Testing Case Study
PDF
End-to-end Testing for IoT Integrity
PDF
Leveraging Static Analysis to Secure Software
PPTX
BUSTED! How to Find Security Bugs Fast!
PDF
Software Development Metrics You Can Count On
PDF
Accelerating Mobile Testing
PDF
C/C++test Qualification Kit for DO-178B/C Compliance
PDF
Extreme Automation Enables DirecTV to ”Shift Left” API Testing
PDF
A Comparison of Three Bug-Finding Techniques and Their Relative Effectiveness
Testing a Microservices Architecture
ABC's of Service Virtualization
The Legend of Software Hollow: Defeating the Headless Horseman of Faulty Appl...
AppsSec In a DevOps World
Driving Risks Out of Embedded Automotive Software
Rx for FDA Software Compliance
Software Safety and Security Through Standards
No Devops Without Continuous Testing
Accelerate Agile Development with Service Virtualization - Czech Test
Evolving from Automated to Continous Testing for Agile and DevOps
Deploy + Destroy Complete Test Environments
MedicAlert API Testing Case Study
End-to-end Testing for IoT Integrity
Leveraging Static Analysis to Secure Software
BUSTED! How to Find Security Bugs Fast!
Software Development Metrics You Can Count On
Accelerating Mobile Testing
C/C++test Qualification Kit for DO-178B/C Compliance
Extreme Automation Enables DirecTV to ”Shift Left” API Testing
A Comparison of Three Bug-Finding Techniques and Their Relative Effectiveness

Recently uploaded (20)

PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Cost to Outsource Software Development in 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
assetexplorer- product-overview - presentation
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
System and Network Administration Chapter 2
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Transform Your Business with a Software ERP System
Understanding Forklifts - TECH EHS Solution
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
PTS Company Brochure 2025 (1).pdf.......
Cost to Outsource Software Development in 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Why Generative AI is the Future of Content, Code & Creativity?
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
assetexplorer- product-overview - presentation
CHAPTER 2 - PM Management and IT Context
Reimagine Home Health with the Power of Agentic AI​
Operating system designcfffgfgggggggvggggggggg
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
System and Network Administration Chapter 2
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Transform Your Business with a Software ERP System

Are Your Continuous Tests Too Fragile for Agile?

  • 1. ParasoftCopyright© 2015 1 2015-05-01 Are Your Continuous Tests Too Fragile for Agile Arthur Hicken Parasoft Evangelist
  • 2. ParasoftCopyright© 2015 22 Arthur Hicken Bio Arthur “Code Curmudgeon” Hicken is heavily involved in the development and testing communities. He is passionate about businesses realizing the full potential of testing solutions. As an expert in his field, Arthur is a sought after speaker regarding testing strategies, efficiencies and results. He has been at Parasoft for over 20 years driving the strategic conversation around SDLC practices that enhance productivity and quality. In addition to holding the title of Evangelist, Arthur represents Parasoft on multiple industry organizations including ICSQ, OWASP, NIST/SAMATE, CWE and more.
  • 3. ParasoftCopyright© 2015 33 Agenda  Challenges of Continuous Agile  Testing defined  Testing is hard (no one wants to do it)  Best practices  A modest proposal: Spring cleaning
  • 4. ParasoftCopyright© 2015 44 The role of QA in Agile  QA is part of development, not an afterthought  Review developer testing efforts  Additional testing of requirements  Iterative during development  Fast discovery and reporting of defects  Investigate root cause of defects  Influence development policy
  • 5. ParasoftCopyright© 2015 55 Challenges of Agile  Need to be fast  Need to be flexible  Testing can be overlooked if not baked in  Architectural compromises from schedule
  • 6. ParasoftCopyright© 2015 66 Challenges of Continuous  Tests must produce binary decision go/no-go  Reuse unit test and functional tests from dev to QA  High level of automation  Requires disciplined mature process  Testing must automatically answer  Is it stable  Will it do what it’s supposed to do
  • 7. ParasoftCopyright© 2015 77 Importance of Testing How do you know when you're done? How do you know if a fix for a minor bug broke a major function of the system? How can the system evolve into something more than is currently envisioned? Testing,both unit and functional,needs to be an integratedpart of the developmentprocess.
  • 8. ParasoftCopyright© 2015 88 Testing delivers A maintained suite of unit tests:  Represents the most practical design possible  Provides the best form of documentation for classes  Determines when a class is "done"  Gives a developer confidence in the code  Is a basis for refactoring quickly
  • 9. ParasoftCopyright© 2015 99 Why Testing is Often Ignored • Too much effort • Too much time • We’re on a schedule – no time to test. • Why is there always time to do it over, but never to do it right? Perceived as “burdensome” • “I don’t need to test my code – I don’t make mistakes.” • Testing means I have to admit that I might have made a mistake. • I don’t like to test – it’s beneath me. • Testing isn’t fun – I just want to code! • That’s for the QA dept. Developer Ego
  • 10. ParasoftCopyright© 2015 1010 Definitions  Unit  Functional  Regression
  • 11. ParasoftCopyright© 2015 1111 Unit Testing Unit tests that validates your method behaves a certain way given a specific parameters  Regressions testing  Validate behavior of existing code hasn’t changed  Scheduled and run automatically  Test Driven Development  Validate behavior of new code to be written  Created before developing, turned into regression tests after
  • 12. ParasoftCopyright© 2015 1212 Functional Testing • Unit tests (Junit, CppUnit, Nunit, etc) • Integration tests • Scripted tests • Manual tests Incarnations of functional tests • Manually written • Machine generated from application tracing • Machine generated from capturing traffic • Machine generated from recording clicks Ways to createfunctional tests
  • 13. ParasoftCopyright© 2015 1313 Regression Testing • Functional unit tests that pass • Machine generated unit tests for current behavior • Unit test written by developers and testers • Tests written to validate bug fixes Contributors to the regression test suite • Unwanted change in behavior – fix the code • Intentional change in specification – update test controls Regression test failures
  • 14. ParasoftCopyright© 2015 1414 What’s the Difference? Unit Tests • The code is doing things right • Written fromprogrammers perspective • Confirm code gives proper output based on specific input Functional Tests • The code is doing the right thing • Written fromusers perspective • Confirm the system does what the user expects it to do Regression Tests • It still works
  • 15. ParasoftCopyright© 2015 1515 Why Do Unit Testing Software bugs are inserted during coding phase, but often aren’t found until functional testing, or worse they are found by customers. The longer a bug stays in the system, the more expensive it is to fix it. Unit testing is a strategy that allows you to find out if your system is behaving the way you expect early in the SDLC. Unit testing allows for easy regression testing, so you can find out quickly whether you have introduced some unexpected behavior into the system.
  • 18. ParasoftCopyright© 2015 1818 What’s Important Unit tests require a LOT of care Unit testing is a continuous operation Test suite maintenance is a commitment Control data (assertions) in the code
  • 19. ParasoftCopyright© 2015 1919 Test incorporation  Take existing unit tests and schedule them into build process  Run and fix tests as part of build process  Ideal goal: 0 failures and 100% code coverage  Realistic goal: 10% test failures and 80% code coverage  If the unit test suite is noisy, don’t qualify the build based on assertion failures
  • 20. ParasoftCopyright© 2015 2020 Unit Test Creation  Maintainability  Proper assertions  Nightly runs  Tests should be:  Automatic (no human input or review)  Repeatable (no strange dependencies)
  • 21. ParasoftCopyright© 2015 2121 Legacy Test Suites  Leverage your existing suite  Clean up incrementally  Set policy based on current results  Tighten policy when in compliance
  • 22. ParasoftCopyright© 2015 2222 Maintaining and Creating UT  Maintaining is more of a problem than creating.  Don’t create a test if you can’t or don’t plan to maintain it.  Creating as you go creates a better test suite  Tests not run regularly become irrelevant
  • 23. ParasoftCopyright© 2015 2323 Write tests with the code Create the test when you’re writing the code Have a test for every task you complete Increases understanding Improve assertions
  • 24. ParasoftCopyright© 2015 2424 Connect Unit Tests  Associate tests with Code and Requirements  Naming Conventions should have meaning  Use code comment tags @task @pr @fr  Use check-in comments @task @pr @fr  Improve change-based testing
  • 25. ParasoftCopyright© 2015 2525 Specific Generation  Don’t be lured by 100% coverage  Auto assertions are not meaningful unless validated  Review the tests as you work on the code
  • 26. ParasoftCopyright© 2015 2626 Code Review Test  Code for unit tests should be reviewed  Consider doing test-design review  Ensures you’re testing what you think you are  Helps reduce noise  Helps improve understanding  Review the code and the test code together
  • 27. ParasoftCopyright© 2015 2727 Testing Exception Handling  Frequently Skipped  Prevents crashes  Prevents death spiral  Rule of thirds  1/3 basic functionality  1/3 advanced features / infrequent settings  1/3 error handling
  • 28. ParasoftCopyright© 2015 2828 All About Assertions  Verifies that the code behaves as intended  True/false  Null or not null  Specific values  Complex conditions
  • 29. ParasoftCopyright© 2015 2929 Why Assert?  Excuses:  My code already has console output  I can check it visually/manually  Binary output (pass/fail)  Part of overall test suite  No human intervention
  • 30. ParasoftCopyright© 2015 3030 Assertion failures Introduced coding error • Fix the new code Functionality changed • Update the assertion Improper assertion • Comment it out
  • 31. ParasoftCopyright© 2015 3131 Assertion Policy  Assign failures as tasks  Author of the test or of the changed code  Try to reach developer that has the highest chance to understand the change  Developer assesses failure:  Bug (fix)  Changed functionality (update assertion)  Bad assertion (improve or remove) - don’t delete; instead, comment out
  • 32. ParasoftCopyright© 2015 3232 What to assert  Ease of creating assertions leads to poor choices  Anything CAN be checked – but should it be?  Assertions should be connected to what you’re trying to test  Assertions should be logically invariant  Check values by range, not equivalence  “What do I expect here logically?”
  • 33. ParasoftCopyright© 2015 3333 How to recognize bad assertions  How often do you WANT to manually verify an assertion?  Daily or near-daily checking indicates poor assertion.  Troublesome possibilities:  Date  User or machine name  OS  Filesystem names and paths
  • 34. ParasoftCopyright© 2015 3434 Missing Assertions  Error was found after code changed  Test suite never caught the error  Update unit-test with new assertion  Write new unit tests as necessary
  • 36. ParasoftCopyright© 2015 3636 The Challenge: Management’s Perspective  Need tests to reduce risks  Testing takes time from features/fixes  Not enough time  Not enough people  Tests and reports lack context
  • 37. ParasoftCopyright© 2015 3737 The Challenge: Development’s Perspective  Hundreds of failing or broken tests  Test requirements unclear  Existing tests are dubious  Deadline pressure
  • 38. ParasoftCopyright© 2015 3838 Spring Cleaning Solution  Throw out the useless, old junk  Identify and eliminate “noisy” tests  Organize the remaining chores  Prioritize unit test tasks  Keep it clean  Establish and follow a routine test maintenance plan
  • 39. ParasoftCopyright© 2015 3939 Throw out the Junk: Identifying Noisy Tests Tests that are fragile • Pass/Fail/Incomplete resultsfrequentlychange • Frequentchangesare requiredto keep up-to-date Tests that are outdated • More than“n” releaseshaveoccurred despitethistest failure • The test appliesto legacy codethat is frozen • The test hasnot been executedfor “x” periodof time Tests that are unclear • It takes more than5 minutesto understand why thetest exists • The failuremessage is incorrect/unhelpful/irrelevant • There is no associated requirementordefect Be merciless!
  • 40. ParasoftCopyright© 2015 4040 Organize Chores: Prioritize Tasks with Policy All tasks are created equal Some tasks are more equal than others Policies establish prioritization and assignment
  • 41. ParasoftCopyright© 2015 4141 Keep it Clean: Establish a Routine Process  Management and Development need to co-define a Policy  Clear testing goals that tie tests to business needs  Clear delineation of responsibility  Test creation and deletion  Test failureresolution  Naming conventions  Peer review  Clear and frequentcommunication  Understand the technical and business impact  Enhance traceability to project requirements  Ask questions  Focus on safety/quality, not coverage  Keep the number of tests minimal  Run all tests on a regularly scheduled, frequent basis  Clean as you go
  • 42. ParasoftCopyright© 2015 4242 Spring Cleaning Recap  Find and delete “noisy” tests  Use policies to prioritize, assign, and plan  Co-design and follow a process to keep it clean
  • 43. ParasoftCopyright© 2015 4343  Web  http://www.parasoft.com/jsp/resources  Blog  http://alm.parasoft.com Social  Facebook: https://www.facebook.com/parasoftcorporation  Twitter: @Parasoft@MustRead4Dev @CodeCurmudgeon  LinkedIn: http://www.linkedin.com/company/parasoft  Google+: +Parasoft +ArthurHickenCodeCurmudgeon  Google+ Community: Development Testing Because its Better