Jasmin & Rhino for JavaScript BDD

Continuous Testing JavaScript with Jasmine and Rhino

“I found the shift from thinking in tests to thinking in behaviour so profound that I started to refer to TDD as BDD, or behaviour driven development.” – Dan North

Jasmine is a BDD framework for JavaScript. It is similar to easyb, which I mentioned previously in my Eclipse plugins round-up. It does have a few problems: running it involves opening a browser, which is cumbersome when doing continuous integration. The Build Doctor has a solution.

Behavior Driven Development is seeing a surge in popularity right now. And with good reason. It allows you to look at tests in a way that is also fairly understandable to people not directly involved with software development.

Jasmine is one framework that eases BDD for JavaScript. However, running Jasmine behaviors can be cumbersome. In its original configuration, Jasmine requires you to open an HTML page in a browser. If you’ve ever tried to automate that, you’ll know there are quite some issues.

In a little magic duct-taping session, Julian Simpson @ The Build Doctor combines Jasmine and Rhino (Mozilla’s JavaScript for Java implementation) with a few choice libraries. The result is JavaScript tests without the browser. Brilliant.

Over the past few months, I’ve become increasingly interested in writing good JavaScript. In part because I have a feeling JavaScript is going to be the language of the next decade. In a bizarre plot twist. JavaScript has become what Java always aspired to: Available everywhere in a fairly standardized manner. Obviously that means developers are also going to want some of the traditional tools to improve their code, including continuous integration, TDD and now BDD. Which is why I think this little trick could be an important step in increasing JavaScript code quality.

Be Sociable, Share!