Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 © Agitar Software, 2007 Automated Unit Testing with AgitarOne Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc. Presented."— Presentation transcript:

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

2 2 © Agitar Software, 2007 Presentation Outline  Unit testing introduction  Good unit test properties  Mock Objects  Continuous Integration and unit tests  Automated Unit Testing with AgitarOne

3 3 © Agitar Software, 2007 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 4 © Agitar Software, 2007 Get It Right: Prevention Saves Money CodingUnit Test Function Test System Test After Release Percentage of Bugs 85% $25 $100 $250 $1000 % Defects introduced in this phase % Defects found in this phase $ Cost to repair defect in this phase $16,000 Source: Applied Software Measurement, Capers Jones, 1996

5 5 © Agitar Software, 2007 Keep It Right: Detect Changes in Code Behavior Continuous Integration Change Code A Impacts Code B Impacts Code C “Sensors” show the impact of code changes High test density brings confidence and agility Continuous integration & test brings the best impact

6 6 © Agitar Software, 2007 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 7 © Agitar Software, 2007 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 8 © Agitar Software, 2007 Continuous Integration Enhances Unit Testing Continuous Integration mechanics –On at least a nightly basis, have a process to: 1.Get the latest version of code from your repository 2.Compile the code 3.Execute all unit tests written for the code 4.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 9 © Agitar Software, 2007 Unit Testing Utopia C1C2 C10C9 C3C6C4 C11 C5 C13C14 C15 C7C8 C12 Our Classes C1C2 C10C9 C3C6C4 C11 C5 C13C14 C15 C7C8 C12 Our Unit Test Classes 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 10 © Agitar Software, 2007 Get Immediate Feedback Report on Progress Find Anti-Patterns Test for the Unexpected Detect Changes in Behavior Code-Rule Enforcement Software Agitation Automated JUnit Generation CruiseControl Management Dashboard AgitarOne is a Complete Unit Test Solution AgitarOne™

11 11 © Agitar Software, 2007 Test for the Unexpected: Software Agitation Fix Bug If observation reveals a bug, fix it! Review Create a JUnit Use automated JUnit generation to create your regression test AnalyzeSummarize Developer 10101 01010 10101 Code AgitarOne Agitation Observations of Code Behavior, and Coverage Data 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.

12 12 © Agitar Software, 2007 Detect Changes in Behavior: Automated JUnit Test Generation Check in Your New Tests AnalyzeFilter & Verify Developer 10101 01010 10101 Code AgitarOne Agitation 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 Review or Accept Standard JUnit Tests

13 13 © Agitar Software, 2007 Avoid Bug-Prone Coding Constructs: Flexible Code Rule Enforcement

14 14 © Agitar Software, 2007 Measure, Manage, and Report: Agitar Management Dashboard 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?

15 15 © Agitar Software, 2007 24x7 Code & Tests Get Immediate Feedback: Continuous Integration and Test Status Store Configuration Management E-Mail 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 Rapid Notification of Changes Dashboard Build Processes

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

17 17 © Agitar Software, 2007 Thank You


Download ppt "1 © Agitar Software, 2007 Automated Unit Testing with AgitarOne Presented by Eamon McCormick Senior Solutions Consultant, Agitar Software Inc. Presented."

Similar presentations


Ads by Google