1 / 17

Automated Unit Testing with AgitarOne

Automated Unit Testing with AgitarOne. Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc. Presentation Outline. Unit testing introduction Good unit test properties Mock Objects Continuous Integration and unit tests Automated Unit Testing with AgitarOne.

smontgomery
Download Presentation

Automated Unit Testing with AgitarOne

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Automated Unit Testing with AgitarOne Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc.

  2. Presentation Outline • Unit testing introduction • Good unit test properties • Mock Objects • Continuous Integration and unit tests • Automated Unit Testing with AgitarOne

  3. Unit Testing Introduction • Unit testing is a procedure used to validate that individual units of source code work properly. A unit is the smallest testable part of an application. In object-oriented programming, the smallest unit is a class and the methods within that class. • Unit tests benefit organizations by: • Improving design • In TDD, unit testing is a design activity! • Eliminating the unknown • Speeding development • Reducing bugs in new and existing features • Allowing safe refactoring of source code

  4. $16,000 % Defects introduced in this phase % Defects found in this phase $ Cost to repair defect in this phase 85% Percentage of Bugs $1000 $250 $100 $25 Coding Unit Test Function Test System Test After Release Get It Right:Prevention Saves Money Source: Applied Software Measurement, Capers Jones, 1996

  5. Change Code A Impacts Code B Impacts Code C ContinuousIntegration Keep It Right:Detect Changes in Code Behavior • “Sensors” show the impact of code changes • High test density bringsconfidence and agility • Continuous integration & test brings the best impact

  6. Properties of Good Tests • Automatic • Should be easy to run • Should not require manual intervention • Should run quickly • Should be integrated into automated build • Thorough • Consider setting coverage targets • Use judgment as to what should be tested • Repeatable • Minimize dependencies on external factors by using mock objects etc. • Independent • Tests should not depend on each other • Test one thing at a time (however a single test can have multiple asserts)

  7. Mock Objects Enable Unit Testing • What are they • Objects that simulate the behavior of real objects • Created by developers to help with testing • When To Use • Need to isolate the code under test from difficult resources (unavailable or non-deterministic) • Behavior is difficult to trigger (e.g. network error) • Real object is very slow • Real object requires user intervention • Real object does not yet exist

  8. Continuous Integration Enhances Unit Testing • Continuous Integration mechanics • On at least a nightly basis, have a process to: • Get the latest version of code from your repository • Compile the code • Execute all unit tests written for the code • Create a report with build and test results “Imperfect tests, run frequently, are much better than perfect tests that are never written at all” – Martin Fowler

  9. Our Classes Our Unit Test Classes C15 C15 C13 C13 C14 C14 C9 C9 C10 C10 C11 C11 C12 C12 C1 C1 C2 C2 C3 C3 C4 C4 C5 C5 C6 C6 C7 C7 C8 C8 Unit Testing Utopia • Every class has unit tests • The tests are executed many times each day • The tests are thorough, up to date, independent and easy to maintain and analyze

  10. AgitarOne is a Complete Unit Test Solution Detect Changesin Behavior Automated JUnitGeneration Get ImmediateFeedback CruiseControl Test for the Unexpected SoftwareAgitation AgitarOne™ Report on Progress ManagementDashboard FindAnti-Patterns Code-RuleEnforcement

  11. ü Analyze Summarize 10101 01010 10101 Code AgitarOne Agitation Observations of Code Behavior, and Coverage Data Fix Bug If observation reveals a bug, fix it! Review Create a JUnit Use automated JUnit generation to create your regression test Validate intended code behavior, interactively • Discover invariants (or specify and validate them) • Achieve high data and state coverage without manual setup • Test without needing application server, database, etc. Developer Test for the Unexpected:Software Agitation

  12. Filter & Verify ü Analyze 10101 01010 10101 Code AgitarOne Agitation StandardJUnit Tests Review or Accept Check in Your New Tests Create a useful set of JUnit tests, automatically • Generate good static tests to detect code behavior changes • Achieve high data and state coverage without manual setup • Reduce the work by 80%+ for thorough JUnit coverage Developer Detect Changes in Behavior:Automated JUnit Test Generation

  13. Avoid Bug-Prone Coding Constructs:Flexible Code Rule Enforcement

  14. ? What code hasn’t been tested ? How rigorous are my tests ? Do I have objective data on quality from outsource partners ? Am I focusing on the most critical code ? What bugs have been found Measure, Manage, and Report:Agitar Management Dashboard

  15. Store 24x7 Code & Tests Configuration Management Status Dashboard Rapid Notification of Changes E-Mail Build Processes Proven best-practice for development productivity • High assertion density  rapid problem detection • AgitarOne has 50,000 tests running constantly • Minutes to feedback, not hours, days, or weeks Get Immediate Feedback:Continuous Integration and Test

  16. Useful Resources • Agitar website: www.agitar.com • Agitar’s Developer Testing Blog: www.developertesting.com • Agitar’s discussion site: http://forums.agitar.com • JUnit Factory – free generated JUnits: www.junitfactory.com • JUnit Homepage: www.junit.org • Test Drive Development Site: www.testdriven.com

  17. Thank You

More Related