Sleepy dog lying next to a wireless keyboard
Hank, rescue pit bull and core maintainer of GoodDogs.js

Dog-Driven Development

An Interview with Hank

Karl Stolley
3 min readApr 1, 2022

--

Call to subscribe to PragProg newsletter
https://pragprog.com/newsletter/

I recently had the opportunity to sit down with Hank after he’d finished breakfast and his morning rawhide chew. For those of you who don’t know him, Hank is a rescue pit bull and core maintainer of the GoodDogs.js assertion library at the heart of dog-driven development. What follows is a transcript of our interview, which has been mercifully edited for length and barking fits at the window.

Karl: Hello, Hank. Who’s a good boy? Thanks for taking the time to discuss GoodDogs.js. For readers who might not be familiar, can you walk us through what dog-driven development (DDD) is?

Hank: [fusses, pushes a toy across the rug]

Karl: I see. So if I’m understanding you correctly, DDD has been strongly influenced by behavioral-driven development, but with a canine set of assertions at its heart. I assume that’s expressed by the GoodDogs.js assertion library. I wonder if you couldn't walk us through an example of its API?

Hank: [pulls up a file, yawns]

const {Treat} = require('../lib/dogthings');
const goodDogs = require('gooddogs');

describe('Dog Things', function() {
describe('a tasty treat', function() { beforeEach(function() {
const treat = new Treat();
});
it('should be so tasty', function() {
goodDogs.expect(treat).to.be.omg('so tasty');
});
it('should not be the only treat', function() {
const treats = [];
for (var i = 0; i < 10; i++) {
treats.push(new Treat());
}
goodDogs.hope.(treats.length).to.be.moarThan(9);
});
});});

Karl: Hmmmmm. I’ve got to say, that doesn’t look a whole lot different from other assertion libraries, like Chai or expect.js. hope() is a method I’ve not seen before. It’s usually just implicit in BDD, traditionally. What else would you say really makes your library unique?

Hank: [abruptly sits up and looks to the window, makes a low growl]

Karl: Diversions? Can you explain what diversions are?

Hank: [makes intense eye contact]

Karl: Oh, that sounds interesting. So diversions are basically a kind of wrapper around Promise objects? What do diversions look like in an actual test?

Hank: [starts typing]

const {Stay} = require('../lib/dogthings');
const goodDogs = require('gooddogs');

describe('Stay', function() {

it('should be easy to stay (but it\'s really not)', function() {
const stay = new Stay();
goodDogs
.expect(stay).to.be.a.diversion('squirrel!')
.ok.so.difficult.diversion('doorbell!')
.ok.no.really.um(function(result) {
this.expect(stay).to.be.executed(result);
});
});
});

Karl: That’s kind of bananas. But I do think that more assertion libraries need an um() method. I wonder whether, in addition to diversion() taking an argument, you might have some convenience methods, too, like .squirrel() and .doorbell()? Those seem pretty common.

Hank: [pants, licks chops]

Karl: [sighs] Yes, okay. I can open an issue about it on GitHub.

Hank: [lays down, closes eyes]

Karl: Looks like we’ve run up hard against your nap time. Thank you for participating in the interview, Hank, and sharing a little bit about your project. Best of luck with it.

Hank: You’re welcome. I need a bath.

Karl: Wait, what?

Hank: [snores]

Karl Stolley’s book, Programming WebRTC: Build Real-Time Streaming Applications for the Web, is available in beta from The Pragmatic Bookshelf. You can save 35 percent with promo code git_config_2022 now through April 30, 2022. Promo codes are not valid on prior purchases.

--

--

Karl Stolley
The Pragmatic Programmers

Author of Programming WebRTC, out in beta at Pragmatic Programmers. Chicagoan. Developer & writer.