The Existence Test
by Gregory Brown
q = F3DQueue.new
Looks pretty simple, eh? You might be quick to say that this doesn't do anything. However, it is actually a pretty clever practice. This test makes sure the tests themselves are working as expected. I was already in the habit of starting with a failure, usually something like:
The purpose of the above is simply to make sure your tests are picked up within your suite, and aren't being overlooked by your Rakefile, autotest, or whatever runner you're using. But the existence test actually goes a little farther. Because you're initializing an object, you're making sure that the files you need to be loading are present, that you can build your objects, *and* that your tests are hooked up.
After you've got a couple tests passing, you can remove this sanity check or morph it into a setup(), whatever makes sense.
Many people think this is a little paranoid, and most of the time, it is. Still, all it takes is one bad experience coding under falsely passing tests, and you'll be converted in no time. :)
I don't get it. Unless you're afraid you might have accidentally said "def F3DQueue.new: return nil; end", what does the assertion add?