I found myself working at a place where they didn't appreciate unit testing. Worse, there were developers there who didn't even know what unit testing was! It can be very intimidating for people who are new to unit testing regardless of how much general software development they've had in the past. These days I find myself working with mostly AngularJS developers. I wanted to boil it down to something people could latch onto. A phrase that describe's (no pun intended) exactly what a spec.js file is. And so I cam up with this quote:
"Describe's full of it's with some beforeEach's."
That all a suite of unit tests is, really- just a describe statement, filled with some it statements, and usually one of two beforeEach statements. This is the Jasmine and chai/mocha syntax for writing unit tests. Once new developers realize this they can then proceed to write a trivial test with all the parts (something like expect 1 + 1 to be 2) and fire up their test runner. Now they've crossed into the land of unit testing. They went from not even knowing where to start to now asking about how to inject services, make mocks, and run only subsections of tests. It's amazing seeing the speed at which programmers progress in their unit testing understanding once they can grasp this one simple phrase: Describes full of it's with some beforeEach's.
The Birth of a T-Shirt
This phrase was so popular and well-accepted by developers in the community that I decided to make it a t-shirt. Yep, I whipped out my Adobe Illustrator skills and and blessed the world with my talents (joking). I wear this t-shirt all the time but especially when I need to buckle down and write a lot of unit tests. I also like to give these out as prizes / volunteer rewards when I'm giving coding talks.
The posts on this site are written and maintained by Jim Lynch. About Jim...