Test Automation Principles


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Test Automation Principles

  1. 1. Test Automation and xUnit <ul><li>Author: </li></ul><ul><ul><li>Carlo Ibarra </li></ul></ul>
  2. 2. Scope Does not cover TDD. Test automation, principles and best practices. xUnit basics.
  3. 3. Terminology <ul><li>SUT – system under test. </li></ul><ul><li>DOC – depended on component. </li></ul><ul><li>Fixture – preconditions to a test; everything a test needs to set up before assertion. </li></ul>
  4. 4. Test Automation “ What I need is a list of specific unknown problems we will encounter.” - a Dilbert Quotes contest entry
  5. 5. Goals of Test Automation <ul><li>Tests should help us improve quality. </li></ul><ul><li>Tests should help us understand the SUT. </li></ul><ul><li>Tests should reduce (and not introduce) risks. </li></ul><ul><li>Tests should be easy to run. </li></ul><ul><li>Tests should be easy to write. </li></ul><ul><li>Tests should require minimal maintenance as the system evolves around them. </li></ul>
  6. 6. Four-Phase Test <ul><li>Fixture Setup </li></ul><ul><ul><li>- test data, mocks, expected results constants </li></ul></ul><ul><li>Exercise SUT </li></ul><ul><ul><li>- Interact with the SUT to exercise desired behavior </li></ul></ul><ul><li>Result Verification </li></ul><ul><ul><li>- Determine if expected outcome is obtained </li></ul></ul><ul><li>Teardown </li></ul><ul><ul><li>- Restore state back to the state before testing </li></ul></ul>
  7. 7. The “Fragile Test” Problem <ul><li>Behavior sensitivity </li></ul><ul><ul><li>Change in requirements, functionality </li></ul></ul><ul><li>Interface sensitivity </li></ul><ul><ul><li>Change in UI </li></ul></ul><ul><li>Data sensitivity </li></ul><ul><ul><li>Change in source structures and state </li></ul></ul><ul><li>Context sensitivity </li></ul><ul><ul><li>- Change in workflow or external DOCs </li></ul></ul>
  8. 8. Principles of Test Automation “ Quality is free, but only to those who are willing to pay heavily for it.” - Lister, Demarco: “Peopleware”
  9. 9. Principle: <ul><li>Write the Tests First. </li></ul>
  10. 10. Principle: <ul><li>Use the Front Door First. </li></ul>
  11. 11. Principle: <ul><li>Communicate Intent. </li></ul>
  12. 12. Principle: <ul><li>Don’t Modify the SUT. </li></ul>
  13. 13. Principle: <ul><li>Keep the Tests Independent. </li></ul>
  14. 14. Principle: <ul><li>Isolate the SUT. </li></ul>
  15. 15. Principle: <ul><li>Minimize Test Overlap. </li></ul>
  16. 16. Principle: <ul><li>Minimize Untestable Code. </li></ul>
  17. 17. Principle: <ul><li>Keep Test Logic Out of Production. </li></ul>
  18. 18. Principle: <ul><li>Verify One Condition Per Test. </li></ul>
  19. 19. Principle: <ul><li>Test Concerns Separately. </li></ul>
  20. 20. Principle: <ul><li>Ensure Commensurate Effort </li></ul><ul><li>and Responsibility. </li></ul>
  21. 21. xUnit Basics “ In order to make an apple pie from scratch, you must first create the universe.” - Carl Sagan
  22. 22. Introducing xUnit <ul><li>Make it easy for developers to write test without learning a new language. </li></ul><ul><li>Make it easy to test individual classes and objects without needing to have the rest of the application available. </li></ul><ul><li>Make it easy to run test or many test in a single action. </li></ul><ul><li>Minimize the cost of running tests so programmers aren’t discourage from running existing tests. </li></ul>
  23. 23. Common Features <ul><li>Specify a test as a Test Method. </li></ul><ul><li>Specify the expected results within the test method in the form of calls to assertion methods. </li></ul><ul><li>Aggregate the tests into test suites that can be run as a single operation. </li></ul><ul><li>Run one or more tests to get a report on the results of a test run. </li></ul>
  24. 24. Q&A