Hacker News new | past | comments | ask | show | jobs | submit login

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.




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.


If you're a python developer, http://www.tdd-django-tutorial.com/ is an excellent resource.


Thanks! Our backend is built on Node, but I'll see if I can glean some general concepts from this.


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...


This looks awesome, thanks! Definitely what I was looking for.


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.


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/



Wow, looks really helpful. I'm definitely going to try out their trial. Thanks!


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).


why is sinon failing to execute in browserify? It's supposed to be stand-alone. Is it being included correctly?


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.


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?


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?


I'd recommend using grunt and karma and avoiding having to list all the files you want to test in an html file.


Uncle Bob's videos on TDD are pretty neat cleancoders.com .




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: