Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
Books

+ - Book Review: Backbone.js Testing->

Submitted by brock8503
brock8503 (3411515) writes "Welcome to the world of large-scale JavaScript web development. Web development is more sophisticated than ever and engineers are building increasingly more complex frameworks to harness the power of the modern browser. Backbone.js is a framework that helps tame large-scale JavaScript web development. However, with more and more emphasis put on building these JavaScript web application it has become even more important for developers to practice good software hygiene by testing JavaScript application code from the start. The book Backbone.js Testing defines a comprehensive list of techniques for testing a Backbone.js application. Readers are introduced to testing methodologies like Test-Driven Development, test reporting, and test mocking. The reader will be taught through examples and will come away with a foundation for building confidence of application quality as their team scales and software grows.

Backbone.js Testing was written by Ryan Roemer, a local Seattle JavaScript aficionado. Ryan co-organizes the Seattle JavaScript meet up. He supports classes that teach topics like Node.js, Backbone.js, and other JavaScript related topic. He is a great source of information and advice. His company Formidable Labs specializes in Backone.js software development.

For those who have had no professional experience with Backbone.js there will be a small amount of ramp up required to understand some of the concepts introduce. However, Backbone.js is designed after a fairly well known software design pattern that many front-end developers have come across, called model view controller (MVC). Backbone.js is a minimalist implementation of the pattern, and provides an effective way to organize web application code for maintainability. Ryan does a good job of quickly introducing Backbone.js, so fear not it is not absolutely necessary to have built software with Backbone.js. Of course for those who have had exposure to Backbone.js, Ryan will keep your interest by detailing several new tools that complement the framework.

To get the most value from this book a reader should have an interest in both JavaScript and general software test practices.

The book begins with an overview of the tools, infrastructure, and methodologies Ryan will introduce to test a Backbone.js web application. Roemer starts by walking through machine preparation, think of this as test bench creation. A good level of exposure to github and UNIX based operating systems will make this section quick and easy. Roemer describes the directory structure to start with, it will make referencing a lot easier later. Along with a Backbone.js application, the test infrastructure is introduced and installed. These tools are Mocha, Chai, and Sinon.JS test libraries. It is recommended that before you get started that you take some time to browse these tools online. There is a lot of development on these tools and it’s always good for more context and reference.

Ryan does a good job describing the utility of each tool and sets the stage for things to come. You will be introduced to the concept of test cases and test reports. He will have you run your very first test case. Ryan provides all the needed links, paths, and code to achieve each task. Be sure to read his extra notes for all the "gotcha's".

Next, you are introduced to the application under test. Ryan provides a fully implemented Backbone.js application. With little exposure to Backbone.js, a novice will quickly wrap their head around this application and all its different pieces. There are a few different components to a Backbone.js application and you learn how each interfaces with the framework. The application under test is called Notes, and it is a basic “sticky note” like application. Each of the major functional components is described so that later you can plan where to focus your testing efforts. The application is pretty impressive in size, and you don’t regularly find a book with such a robust example. Give kudos to Ryan for providing a great example application. Make sure to download the application and play around with it. Get a sense for the functionality and put some extra thought into areas you think bugs could live.

The core subject matter is detailed in the third chapter of the book. Ryan takes a deep dive into a few test methodologies, test planning, and test case authoring. In this chapter you will learn about unit testing and integration testing and the roles they play. It will detail Behavioral-Driven Development and Test-Driven Development. Behavioral-Driven Development (BDD) is a great paradigm for describing test cases, you will find it refreshing. Be sure to study this chapter, it is critical to understand. If you find it hard to follow along, you should spend a little more effort taking notes and following up with online research. In the later chapters you will build on this foundation of knowledge. Roemer clearly introduces concepts and openly admits to showing application implementation first and test cases second. If you are familiar with Test-Driven Development, you may want to see how the book would read if Ryan had introduced the concepts in true Test-Driven Development fashion.

Spies and stubs and mocks, (oh my!) In the next two chapters, you get your hands dirty with a set of higher-order test patterns. Many developers in the wild might not have had any exposure to spy, stub, or mock test patterns. These patterns are very powerful, require a commitment to testing, and will affect the design of your software from the very start. Luckily, Backbone.js is well suited for these test patterns. Sinon.js is the JavaScript framework you can leverage. Ryan will show how to decouple Backbone.js components without needing to add additional test hooks in code and write test cases that can test each component in isolation. If you remember, 70% of testing should be done in isolation to verify the units of functionality; this will flush out most errors in your code early on. The spies, stubs, and mocks examples are going to be great references when you start testing your application.

The last chapter Ryan offers an additional test approach. You learn about a new tool called Phantom.js, a headless browser for testing a web application. Phantom.js is an integration test framework. Phantom.js can automatically test components when they are glued together and executing in a browser container. This subject could have had a few chapters written on it, but you are instead introduced to the topic and provided with additional resources to follow up with on your own time.

Roemer provides a well-planned set of steps for building a comprehensive test strategy for a Backbone.js web application. The book clearly delivers on the topic and readers who are looking for a set of tools and a good reference for using them to test better won’t be disappointed. The book is only 147 pages, so take care with the topics; there can be a lot of information in a relatively short amount of time. Take notes and follow along with the examples as Ryan suggest, and most of all have fun.

Kyle McFarland, co-founder and engineer at a Seattle startup.

I am a lead engineer at a local startup and our technology stack is built using JavaScript. We don’t have experience with Backbone.js, but are very interested in leveraging it in the future. Previously, I worked as a Software Developer in Test at both Microsoft and Intel and have a good understanding of the domain. Ryan and I work in the same JavaScript technology groups and I have leveraged his expertise on several occasions. I was thrilled to read and review this book."

Link to Original Source
This discussion was created for logged-in users only, but now has been archived. No new comments can be posted.

Book Review: Backbone.js Testing

Comments Filter:

"No job too big; no fee too big!" -- Dr. Peter Venkman, "Ghost-busters"

Working...