News for hackers. Stuff that matters.
Re:Testing at Airbnb by elsbree on Thursday February 27, 2014 @03:09PM (#7314657)
Does anybody have recommendations for where/how to start learning best practices for TDD?

As (nominally) top nerd at a tiny startup (2 engineers), I feel like I should set a precedent sooner rather than later for testing. This is currently not possible since I don't know anything about it, so any resources would be appreciated :)

Edit: Primarily looking for resources involving Node.js and client-side testing of a jQuery-based website.

Re:Testing at Airbnb by mseebach on Thursday February 27, 2014 @05:42PM (#7315777)
TDD isn't a tool or a library, and thus isn't specific to a language or a framework - it's a philosophy.

Get, read and understand Kent Beck: "Test driven development by example". The rest will follow naturally.

Re:Testing at Airbnb by hoka on Thursday February 27, 2014 @03:49PM (#7314952)
If you're a python developer, http://www.tdd-django-tutorial.com/ is an excellent resource.
Re:Testing at Airbnb by elsbree on Thursday February 27, 2014 @03:54PM (#7314981)
Thanks! Our backend is built on Node, but I'll see if I can glean some general concepts from this.
Re:Testing at Airbnb by 2mur on Thursday February 27, 2014 @04:09PM (#7315082)
For node + browser, I'm partial to substack's tape module[1][2] to output tap. Works great with browserify too.

[1] https://github.com/substack/tape

[2] http://www.catonmat.net/blog/writing-javascript-tests-with-t...

Re:Testing at Airbnb by elsbree on Thursday February 27, 2014 @05:03PM (#7315493)
This looks awesome, thanks! Definitely what I was looking for.
Re:Testing at Airbnb by jimejim on Friday February 28, 2014 @09:19AM (#7318779)
Along with what everyone else mentioned, if you like podcasts, this one gave me some good insights along with the blog:

http://www.sustainabletdd.com/

One aha moment for me that's talked about here is to treat your tests more as a form of documentation and specification of how to use the system. They talk about how you should even do some basic tests to confirm enumerations and constants in the system as a way to be clear about their use.

You don't always have to be as thorough, but the mental shift from test to specification was helpful for me.

Edit: Unfortunately, if you download this podcast it's a bit out of order, so you want to read the blog and use it as a guide for which order to listen to things. They're in the process of writing a book about TDD and this blog is part of their process.

Re:Testing at Airbnb by davidjnelson on Thursday February 27, 2014 @09:08PM (#7316815)
Growing Object Oriented Software Guided By Tests is a great book on the topic: http://www.amazon.com/Growing-Object-Oriented-Software-Guide...

Misko Hevery's (also happens to be creator of angularjs!) Testability Explorer blog is also a great resource: http://misko.hevery.com/category/testability-explorer/

Re:Testing at Airbnb by jcagalawan on Thursday February 27, 2014 @04:07PM (#7315067)
Re:Testing at Airbnb by elsbree on Thursday February 27, 2014 @04:28PM (#7315225)
Wow, looks really helpful. I'm definitely going to try out their trial. Thanks!
Re:Testing at Airbnb by warfangle on Thursday February 27, 2014 @04:39PM (#7315298)
I've been setting up client side testing with grunt+browserify+karma+jasmine lately. It's pretty freaking powerful. But, none of the usual suspects for mocking http.get requests work well with it (sinon fails to execute in a browserify test environment; nock expects to be running in a node environment with the ClientRequest object available).
Re:Testing at Airbnb by ulisesrmzroche on Thursday February 27, 2014 @06:23PM (#7316027)
why is sinon failing to execute in browserify? It's supposed to be stand-alone. Is it being included correctly?
Re:Testing at Airbnb by warfangle on Thursday February 27, 2014 @06:38PM (#7316135)
https://github.com/cjohansen/Sinon.JS/pull/358

Longer story:

using npm to install sinon; shimming sinon in my karma browserify plugin config (`'sinon' : 'global:sinon'`)since it doesn't follow CommonJS; using browserify (and the karma browserify plugin) to require('sinon'); sinon is undefined after var sinon = require('sinon'). Might be something up with my config, but none of the other non-commonjs modules I shim (jquery, swfobject) have the same issues.

Re:Testing at Airbnb by ulisesrmzroche on Thursday February 27, 2014 @06:22PM (#7316020)
When writing tests, the key to remember is to write what you wish you had. Othe than that, are you on Express.js? Also, have you ever tried QUnit?
Re:Testing at Airbnb by elsbree on Thursday February 27, 2014 @07:56PM (#7316560)
Yes, we're using Express.js. QUnit looks interesting, I think I'll start with it. Is it pretty standard to just have an HTML file that runs all your client-side tests?
Re:Testing at Airbnb by davidjnelson on Thursday February 27, 2014 @09:11PM (#7316831)
I'd recommend using grunt and karma and avoiding having to list all the files you want to test in an html file.
Re:Testing at Airbnb by csgavino1 on Thursday February 27, 2014 @11:10PM (#7317197)
Uncle Bob's videos on TDD are pretty neat cleancoders.com .