In test-driven development (TDD), a software developer first creates some specific tests that are intended to fail and then writes code that is good enough to pass the tests. After that, the code is refactored, improved to make it better and easier to maintain and extend.
A key goal of TDD is to reduce the time and costs required to develop software.
Daniel Hinojosa’s well-written Testing in Scala effectively introduces test-driven development basics to Scala newcomers, as well as to developers already familiar with Scala or other programming languages, including Java, Ruby or Python.
The scala-lang.org website describes Scala as “a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application.”
Both TDD and Scala have been around for a number of years, but each is now gaining new traction with corporations, software companies, and individual developers seeking faster results at lower costs.
One big reason for Scala’s rising popularity, the Scala website proclaims, is Scala’s close ties to Java:
“Existing Java code and programmer skills are fully re-usable. Scala programs run on the Java VM, are byte code compatible with Java so you can make full use of existing Java libraries or existing application code. You can call Scala from Java and you can call Java from Scala; the integration is seamless. Moreover, you will be at home with familiar development tools, Eclipse, NetBeans or IntelliJ for example, all of which support Scala.”
The Spring Tool Suite also can support Scala using the Scala IDE for Eclipse, but there recently were a few “caveats” if you have the Java 7 JDK installed. Meanwhile, the Spring Scala project, announced last October, is underway.
The new book Testing in Scala is structured as six chapters that utilize different testing frameworks while an example application is tested and developed from scratch:
- Structure and Configuration of Simple Build Tool (SBT)
The book and its code examples, Hinojosa says, are “organized in a TDD fashion: test first, fail; test again, succeed maybe; test again, succeed, and so on.”
If you’ve never tried TDD, Testing in Scala may help you learn how to become a better, more efficient Scala developer.
It also can introduce you to a development style that you may be able to adapt quickly and effectively to other programming languages, as well.
— Si Dunn