Book review: Test-Driven JavaScript Development
Over the holidays I finally had some time to work on my stack of books to read. One of the books on top of my list was Test-Driven JavaScript Development by Christian Johanson.
As I am working with with all different kinds of testing in different languages -- one of them JavaScript -- for quite some time now I didn't expect to learn a lot of new things, but you never know. I like to hear about different approaches and point of views, as these present fresh ideas and different ways of thinking. This book provided my with all different kinds of new perspectives.
The book is mostly directed at developers new to TDD (Test-Driven-Development). It provides a profound introduction to this topic using easy to understand examples from the JavaScript world.
The chapters in detail
I decided to provide you with a short overview of the different sections in the book accompanied by one or two sentences describing what you have to expect from those. Hopefully this will give you the information to decide whether this book is what you are looking for. The following list is not an exact copy of the chapters you will find in the book. It rather presents logical units of explanation I think are worth mentioning. Therefore the here provided sections often cover more than one chapter of the book.
Introduction to TDD
The author starts by giving an overview about what automated tests are, explaining all the needed vocabulary like assertions, test functions, test cases, test suites, …. After that it is detailed why and in which way TDD changes the way you develop software to the better.
Tools of the Trade
In the world of JavaScript a lot of different testing frameworks and tools does exist. All major players are presented. There pros and cons are detailed and examples of their usage is shown. This chapter provides all the necessary information for the reader to decide which kind of framework he or she wants to use for his or her own project.
JavaScript for Programmers
This section, which is covered by a lot of different chapters provides inside to the inner workings of the JavaScript programming language. A lot of questions are answered: What are functions exactly? How does prototypal inheritance work? What are closures? What's about the 5th Edition of ECMAScript?.
Even though these chapters seem to only cover information about normal software development with JavaScript instead of information about testing, the author does combine these two aspects very well. Using a test-driven approach to explain all of these features to the reader he is capable of providing a lot of JavaScript knowledge, but to show how unit tests work in all different kinds of situations.
Feature Detection
In today's segmented world of browsers it is more important than ever to detect which features a browser does support. The according chapter does not only provide ways of doing exactly this, but explains how unit tests can help you easily ensure browser compatibility of your application.
Real-World Examples
The next section of the book does provide a more sophisticated look at ways to unit test applications by utilizing real world problems: Observer pattern, Ajax abstraction and a COMET based chat client.
Even though these examples are stripped down to the bare minimum to fit into the book, they provide an interesting insight into problems and their solutions, which arise while handling unit tests in the real world.
Server-Side Testing with node.js
JavaScript is getting more interesting for the server-side every day. Projects like node.js provide all the necessary means to create powerful JavaScript based server backends. As unit testing inside such an environment is a little bit different from all of the before presented browser tests the author decided to detail these differences using a chat application backend as real world example.
Testing Patterns
The book concludes with some chapters about testing patterns which have been well-established over the years. It is explained in detail what stubs and mocks are, how they can be used to ease and decouple tests, as well as what frameworks exist to assist you in doing so.
Conclusion
As I stated at the beginning of my review, I didn't learn much new from this book. This is mostly due to the fact, that I am working with all of these technologies for quite some time know, which allow me a great insight into this world. I have however been provided with a new angle to look at different problems and solutions, which will most likely help me to be even more efficient in the future.
The way the author uses unit tests to explain some of the enhanced concepts of JavaScript itself is a very interesting approach to impart knowledge. Seeing the corresponding test next to the explained functionality helps understanding the expected results and behavior a lot.
Therefore this book might be a good choice for you, if you are either interested in learning advanced JavaScript concepts or Test-Driven-Development. It is perfect of course, if you intend to learn both.
Christian on Wed, 12 Jan 2011 15:45:31 +0100
Thanks for the review Jakob! Glad you found some useful perspectives in it even though you are already a well-versed tester :)
Link to commentSergey on Mon, 02 Jul 2012 19:32:30 +0200
Thanks for your review!
Link to comment