Software Quality Insights

A SearchSoftwareQuality.com blog

» VIEW ALL POSTS Nov 8 2013   11:41PM GMT

Scala testing book illustrates effective use of TDD for Scala projects



Posted by: James Denman
Tags:
Automated Test Design
automation
Automation Test
BDD
TDD

Weighing in at under 150 pages, Testing in Scala by Daniel Hinojosa is a quick, project-based introduction to using a test-driven or behavior driven approach to testing in – you guessed it – the Scala programming language.

Hinojosa explains in the preface that the book started with an article, which led to a No Fluff, Just Stuff presentation, which led to the creation of the book. The book recommends a test driven development (TDD) or behavior driven development (BDD) approach to Scala testing and software development.

I’d recommend it for developers who are either familiar with or learning Scala and have reason to pick up TDD or BDD; for developers that are familiar with TDD or BDD and have reason to learn Scala; and for software quality professionals that have reason to learn the coding end of automated test scripting in BDD or TDD.

The book assumes the reader already has some experience with Scala. The authors do suggest several good ways for readers to learn Scala, but this book will not teach testers Scala on its own. If you’re not already comfortable with Scala you’ll likely have to do some pre-learning to get real value from this book.

The book only covers one particular open-source build tool designed to facilitate TDD for Scala projects and two testing frameworks and an automation tool that all work with that tool. The limited scope however, can be helpful in that the author is able to provide very concrete examples of how to set-up, configure, and use each Scala testing tool. Hinojosa does a good job of livening up the potentially dry code learning with example projects that focus on various popular musicians.

The tool Hinojosa suggests using is called Simple Build Tool (SBT) and it is still “bleeding edge” as the author puts it. Version 1.0 is still under development. However, in a truly Agile spirit, version 0.11.0 – which the book uses in its code examples – is already delivering value. The testing frameworks he suggests are ScalaTest (a full BDD test suite) and Specs2 is similar framework with subtle differences that make it easier for developers to customize the tests to fit their needs.

Testing in Scala keeps a good pace. It runs the reader through 6 chapters, each of which can easily be read in a single sitting. It’s a good idea to skim the preface as well, to get a feel for what you’ll find in the rest of the book. Following one chapter each night should allow even busy developers and testers to pick up on the value of TDD for Scala projects in their spare time over the course of a week.

Chapter 1 explains the setup for SBT in general as well as the frameworks and examples used I the book. Chapter 2 covers SBT itself, its configuration and structure. Chapters 3 and 4 cover the test frameworks ScalaTest and Specs2 respectively. Chapter 5 covers the mocking techniques that aid in unit testing without the need for extensive test data. Chapter 6 really brings it home by explaining how to automate Scala testing with ScalaCheck.

So until next time, remember not to put off till tomorrow what you can do today, and to get the rest automated so you don’t have to mess with it at all.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: