Your SlideShare is downloading. ×
0
Introduction to Automated Testing by Lars Thorup, ZeaLake May 26th 2011
Who is Lars Thorup? <ul><li>Software developer
Coach: Teaching TDD and automated testing
Advisor: Assesses software projects and companies
Founder and CEO of BestBrains and ZeaLake </li></ul>
Why are we here today? <ul><li>How do we do automated testing? </li><ul><li>Write test programs
Run the tests automatically </li></ul><li>Why should we write tests? </li><ul><li>Enjoy more efficient and predictable cou...
Find and fix bugs fast
Prevent bugs from reappearing
Improve the design of our software </li></ul></ul>
Different kinds of automated tests <ul><li>Unit tests </li><ul><li>Tests individual pieces of code and the interaction bet...
Unit tests or system tests? <ul><li>Unit tests are  efficient </li><ul><li>Fast to run (a few seconds)
Robust and predictable
Easy to write
Is written together with the code it is testing </li></ul><li>System tests are  thorough </li><ul><li>Tests all layers tog...
Upcoming SlideShare
Loading in...5
×

Introduction to Automated Testing

2,492

Published on

Learn about the benefits of writing unit tests. You will spend less time fixing bugs and you will get a better design for your software. Some of the questions answered are:

Why should I, as a developer, write tests?

How can I improve the software design by writing tests?

How can I save time, by spending time writing tests?

When should I write unit tests and when should I write system tests?

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,492
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
41
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to Automated Testing"

  1. 1. Introduction to Automated Testing by Lars Thorup, ZeaLake May 26th 2011
  2. 2. Who is Lars Thorup? <ul><li>Software developer
  3. 3. Coach: Teaching TDD and automated testing
  4. 4. Advisor: Assesses software projects and companies
  5. 5. Founder and CEO of BestBrains and ZeaLake </li></ul>
  6. 6. Why are we here today? <ul><li>How do we do automated testing? </li><ul><li>Write test programs
  7. 7. Run the tests automatically </li></ul><li>Why should we write tests? </li><ul><li>Enjoy more efficient and predictable course of development
  8. 8. Find and fix bugs fast
  9. 9. Prevent bugs from reappearing
  10. 10. Improve the design of our software </li></ul></ul>
  11. 11. Different kinds of automated tests <ul><li>Unit tests </li><ul><li>Tests individual pieces of code and the interaction between code blocks </li></ul><li>System tests </li><ul><li>Tests the entire system against the requirements </li></ul><li>Performance tests </li><ul><li>Tests non functional requirements </li></ul></ul>
  12. 12. Unit tests or system tests? <ul><li>Unit tests are efficient </li><ul><li>Fast to run (a few seconds)
  13. 13. Robust and predictable
  14. 14. Easy to write
  15. 15. Is written together with the code it is testing </li></ul><li>System tests are thorough </li><ul><li>Tests all layers together
  16. 16. Most efficient way to create a set of tests for existing code </li></ul></ul>
  17. 17. Can we automate performance tests? <ul><li>Performance tests are brittle </li><ul><li>Tip: create performance trend curves instead </li></ul></ul>
  18. 18. So, how do we actually do this? <ul><li>IsNumeric </li><ul><li>C#
  19. 19. Ruby </li></ul><li>TransferFunds </li><ul><li>C++ </li></ul></ul>
  20. 20. How do we run the tests automatically? <ul><li>From our programming environment (IDE) </li><ul><li>Command line: make test
  21. 21. Right click | Run Tests </li></ul><li>On every commit </li><ul><li>Setup a build server </li><ul><li>Hudson / Jenkins
  22. 22. TeamCity </li></ul><li>Let the build server run all tests
  23. 23. Get build notifications
  24. 24. Keep the build green </li><ul><li>Fixing a broken build has priority over any other development task </li></ul></ul></ul>
  25. 25. How can tests help improve our design? <ul><li>The software design needs to evolve over time
  26. 26. A refactoring modifies the design without changing behavior
  27. 27. Tests ensure that behavior is not accidentally changed
  28. 28. Without tests, refactoring is scary </li><ul><li>and with no refactoring, the design decays over time </li></ul><li>With tests, we have the courage to refactor </li><ul><li>so we continually keep our design healthy </li></ul></ul>
  29. 29. What is good design? <ul><li>One element of good design is loose dependencies </li><ul><li>Use interfaces (for static languages)
  30. 30. Inject dependencies </li></ul><li>Avoid this
  31. 31. Do this instead </li></ul>
  32. 32. Are we wasting valuable developer time writing tests? <ul><li>No
  33. 33. The time spent writing tests is not taken from the time spent coding </li><ul><li>It is taken from the time otherwise spent on manual testing and debugging </li></ul><li>The cost of a bug keeps increasing until we fix it
  34. 34. Find bugs fast </li><ul><li>Avoid losing customer confidence
  35. 35. Free QA to do exploratory testing so they find the hard-to-find bugs
  36. 36. Spend less time trying to figure out what is causing the bug and how to fix it </li></ul><li>Avoid spending time testing again </li></ul>
  37. 37. How do we get started? <ul><li>When we have a lot of existing code without tests </li><ul><li>Create a set of system tests to get a safety net </li></ul><li>When we are writing new code </li><ul><li>Write unit tests in conjunction with the new code </li></ul><li>Set up a standard test environment for our specific application </li><ul><li>Test data </li><ul><li>Automate the creation of standard testdata in a local database </li></ul><li>External dependencies </li><ul><li>Write stubs to use in the tests </li></ul></ul></ul>
  38. 38. What does a real-world project look like? <ul><li>wizerize.com </li><ul><li>Web application: C# and JavaScript
  39. 39. 3 years of production
  40. 40. 2-4 developers </li></ul><li>40% test code, 60% production code (in lines of code)
  41. 41. 71% code coverage of unit tests
  42. 42. 614 unit tests – run in 1 minute
  43. 43. 54 system tests – run in 20 minutes
  44. 44. No functional errors seen by end users in production (yet) </li></ul>
  45. 45. Where can I read more? <ul><li>http://googletesting.blogspot.com/
  46. 46. http://testdrivendeveloper.com/
  47. 47. http://codesheriff.blogspot.com/ </li></ul>
  48. 48. Which tools do we use? Environment Tool C# NUnit JavaScript qUnit HTML-based UI WatiN, Selenium C++ CppUnit, googletest Python unittest Ruby Test::Unit C check, cunit Java JUnit ... ...
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×