PageRenderTime 2153ms CodeModel.GetById 2138ms RepoModel.GetById 1ms app.codeStats 0ms

/eclipse-plugin/plugins/com.google.test.metric.eclipse.doc/doc/TestabilityExplorer.html

http://testability-explorer.googlecode.com/
HTML | 42 lines | 37 code | 5 blank | 0 comment | 0 complexity | 2a7323cc496fc8227147bc27ee9b0422 MD5 | raw file
Possible License(s): Apache-2.0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>What is the Testability Explorer</title>
  5. </head>
  6. <body>
  7. <h2>
  8. What is the Testability Explorer
  9. </h2>
  10. <p>
  11. Testability-explorer is a tool which analyzes Java bytecode and computes how difficult it will be to write unit tests for the code. It attempts to help you quantitatively determine how hard your code is to test, and where to focus to make it more testable.
  12. </p>
  13. <p>
  14. Testability Explorer can be used:<br/>
  15. <ol>
  16. <li> As a learning tool which flags causes of hard to test code with detailed breakdown of reasons. </li>
  17. <li> To identify hard to test hair-balls in legacy code. </li>
  18. <li> As part of your code analysis-toolset. </li>
  19. <li> As a tool which can be added into continuous integration that can enforce testable code. </li>
  20. </ol>
  21. </p>
  22. <p>
  23. Currently the tool computes:<br/>
  24. <ol>
  25. <li> Non-Mockable Total Recursive Cyclomatic Complexity. Cyclomatic Complexity is a measure of how many different paths of execution are there in the code. It is computed, by counting the if, while, and case as branching primitives. It is recursive because cost of the method as well as any methods it calls are counted. It is total because cost of object construction as well as any static initializations are counted. And finally, it is non-mockable because any code which can be mocked out in test is not counted as part of the cost. This means that the score is based on the amount of complex code that cannot be mocked out in a unit test. </li>
  26. <li> Global Mutable State. Counts the number of fields which are globally reachable by the class under test and which are mutable. Mutable global state makes testing difficult as tests are not isolatable, the global state needs to be set up and cleared between tests. </li>
  27. <li> Law of Demeter. This is the principle that calling methods on objects you get from other collaborators is trouble, instead, the collaborator should call that method itself. It makes testing harder because your mocks must expose some internal state through these methods. </li>
  28. </ol>
  29. </p>
  30. <p>
  31. For more information about testability explorer, please visit <a href="http://code.google.com/p/testability-explorer">http://code.google.com/p/testability-explorer</a>
  32. </p>
  33. <p>
  34. For a demo of testability-explorer in action see <a href="http://testabilityexplorer.org/report">http://testabilityexplorer.org/report</a>.
  35. </p>
  36. </body>
  37. </html>