Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

This page walks you through a simple TDD kata

git clone the code from git clone https://livingwater@bitbucket.org/living-water-js/tdd-walkthrough.git

Pre-requisite knowledge

  • How to install a the unit testing framework for the particular language

  • An understanding of why testing is important

  • How to write a unit test and run the test

  • The three A's (Arrange, Act, Assert)

  • Writing incremental tests and why this is important - one test, some production code, then next test and some production code

...

Code Block
class StringSplitter
{
    splitString( stringToSplit )
    {
        var result = [];

       var tempResult = stringToSplit.split( ',' );
        
        console.log( tempResult );

        if( tempResult[0]stringToSplit.length > 10 )
            result = tempResult.push(stringToSplit);

        return result;
    }

}

Phase 3

...

Code Block
class StringSplitter
{
    splitString( stringToSplit )
    {
        var result = [];

       var tempResultif( = stringToSplit.split( ','length > 0 );
        console.log("tempResult:");{
        console.log( tempResult );  var tempResult = stringToSplit.split( ',' );
 console.log(tempResult.length );          if( tempResult.length > 0 )
                result = tempResult;
        }

        return result;
    }
}