Test-driven development: Difference between revisions

Content deleted Content added
Line 22:
== Differing styles ==
 
There are various ways one can go about using TDD and the most common one is based on KISS (Keep it simple stupid) or YAGNI (You aren't going to need it). This style focuses on writing code anyway necessary in order to pass the tests. Design and properyproperty principles are cast aside in the name of simplicity and speed. Therefore, any rule can be violated as long as the tests will pass. This can be unsettling for many at first but it will allow the programmer to focus only on what is important. However, the programmer must pay a bigger fee in the [[refactoring]] step of the cycle since the code must be cleaned up to a reasonable level at this point before the cycle can restart.
 
Another variation of TDD requires the programmer to first fail the testcases. The idea is to ensure that the testcase really works and can catch an error. Once this is shown, the normal cycle will commence. This is one of the more popular variations and has been coined the "TDD Mantra", known as red/green/refactor where ''red means fail'' and green is pass.