TDD scala trick
There exists a Predef object in the Scala language:
The
Predefobject provides definitions that are accessible in all Scala compilation units without explicit qualification.
It is composed of many common helpers such as printf and assert.
There’s also this interesting one:
def ??? : Nothing = throw new NotImplementedErrorThe use?
???can be used for marking methods that remain to be implemented.
This is perfect for TDD. Input and Return types can even be specified, and best of all the code will still compile.
def deserializeMessage(input: Array[Byte]): String = {
???
}
// explicitly:
def deserializeMessage(input: Array[Byte]): String = {
scala.Predef.???
}This means we can go write some failing unit tests, come back and write the code to make the tests pass.