Successfully reported this slideshow.

Unit Testing Basics

1,698 views

Published on

Slides form very basic introductory talk about unit testing.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Unit Testing Basics

  1. 1. Unit Testing Basics Serhiy Oplakanets @ Mavenresearch, November 2010 Slides are not intended to make sense outside of the talk.Thursday, November 18, 2010
  2. 2. A Discipline • Unit Testing is a discipline of Quality Assurance • Others Include: • Functional Testing • Integration Testing • Code Review • Continuous Integration • ...Thursday, November 18, 2010
  3. 3. Unit Testing is • validating that individual units of application work properlyThursday, November 18, 2010
  4. 4. Benefits • Finding bugs early • Less debugging • Changes to application are safer and easier • Examples of code usage • Documentation (to some extent) • Unit test is a tool to validate code design; in most cases code that is hard to test is badly designedThursday, November 18, 2010
  5. 5. Good Unit Test • Test only one unit at a time • Do not depend on ordering of test run • Runs fast • Tests only one feature at a time • Easy to understand • Tests the public API of unit • Covers all usage casesThursday, November 18, 2010
  6. 6. Test Suite • Multiple tests form Test Suite • Your most important tool to check impact of changes • Helps estimate changesThursday, November 18, 2010
  7. 7. Good Unit Test Suite • Is simple to run • Runs fast (preferable in seconds) • Is always Green • Is non-interactiveThursday, November 18, 2010
  8. 8. Limitations of Unit Testing • Not every bug can be found by unit tests • As were testing only one module -- integration issues are not covered • Multi-threaded issues cant be caught by one- threaded test • Hardware failures, 3rd party component issues, etc. All those can be covered only with a proper Functional Test SuiteThursday, November 18, 2010
  9. 9. Practical SessionThursday, November 18, 2010
  10. 10. Resources • http://en.wikipedia.org/wiki/Unit_testing :) • http://blog.stevensanderson.com/ 2009/08/24/writing-great-unit-tests-best- and-worst-practises/ • http://googletesting.blogspot.com/2008/11/ clean-code-talks-unit-testing.html • http://geosoft.no/development/Thursday, November 18, 2010
  11. 11. Thank you.Thursday, November 18, 2010

×