More tests – REPEAT

If you remember form the TDD testing cycle, we had RED-GREEN-REFACTOR-REPEAT. We are not at a stage where we can refactor our code, as there is not enough of it yet. So, we skip this step and move to REPEAT, that is, writing more failing tests and then writing application code to fix them. Some of the tests may seem to have overlapping boundaries, but we will leave them be for now.

Let's fill in our pending tests one at a time:

it should "convert a number 245 into a binary number 11110101" in 
{   
  val binary:Binary = BaseConversion.decimalToBinary(Decimal("245"))     
  assert(binary.number == "11110101") 
}

Now we are at a point where we need a more generic conversion algorithm for decimal to binary. So we will start writing our implementation. ...

Get Scala Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.