anchor.diff:  = The Rationale for Testing
   :published_at: 2011-05-17
  -:hp-tags: Unit test, TDD, Mocking
  +:hp-tags: Unit test, TDD, Mocking, Testing, Integration
   
   
   
  
positive.code: * The test should be easily understood and maintainable.
  
  
  With that in mind, the following goals should be brought in mind: 
  
  * Tests are thorough and express behaviour not methods. A unit test provides a strict, written contract that the piece of code must satisfy. 
  
  * Tests enables shorter feedback development cycles, enabling finding of problems early in the development cycle.
  * Tests are repeatable. All unit tests should be able to be run repeatedly and continue to produce the same results, regardless of the environment in which the tests are being run.
  * Tests should have a clear intent so they're easily understood. 
  * Tests should be kept up-to-date to reflect the current behaviour of the unit.  
  * Tests are kept clean for easy maintainability. We should take the same care we take with test code as we do for production code. 
  
  
  
negative.code: Finally unit tests add value both implicitly and explicitly:
  
  * A set of unit tests acts as a regression test suite.
  * Production code is documented through test code. Want to know what the software does, read the tests!
  * Simplifies integration. Unit testing helps to eliminate uncertainty in the units themselves and can be used in a bottom-up testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration testing becomes much easier.
  * It forces developers to think more about their code.
  * It improves the design of the code: you have to make your code testable, so you’ll make sure to separate concerns better.
  * It enables refactoring. Tests become a bedrock to inform you if changes have broken functionality.
  
  
  
  Hopefully these thoughts will get you in the right mindset when writing your own tests. 
   
  