O'Reilly logo

Scala Test-Driven Development by Gaurav Sood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required