Test Driven development (TDD)

Test First or Test Driven development is a design pattern that can be summed up as:

  1. Write a test case and fail it (RED)
    ~ This means create your unit tests referencing classes that do not exist
    ~ the project will not compile

  2. Put enough code to pass (GREEN)
    ~ This mean create the signature of the classes & methods you are testing (sometimes referred to as stubbing them out)
    ~ Return a default value, example if the return type is int then return 0

  3. Re factor (REFACTOR)
    ~ Implement the methods with the intended logic
    ~ Run test cases Pass/Fail

TDD

What is the value?

* High test coverage (You are forced to write Unit Tests)
* Intentions & requirements are clear
* Iterative development and testing
* Defects are identified early
* Automatic regression

Also see: https://dzone.com/articles/fail-fast-principle-in-software-development

References