Extra Cheese

A Blog


Dingus Screencast: A mock/stub library with automatic isolation

Apr 01, 2009

Dingus is a mocking/stubbing library I've been working on for about a year. It grew out of a now-defunct project's test suite, and I've used it in about 3,500 lines of unit test code. It does two things that are pretty novel:

  1. A dingus allows you to do almost anything to it, including nesting accesses arbitrarily deep. If you have a dingus d, you can say 99 * (d.foo.bar.baz() ** 'hello')[15] and you'll just get another dingus out. This lets you use dinguses to replace dependencies in legacy code without thinking about what interface they must conform to.
  2. If you want it to, Dingus can automatically replace your dependencies with dinguses. You just tell it what class you're testing, and it will replace everything else in that class's module with a Dingus. This fully isolates your code under test without requiring any work from you.

The second point above is probably a bit hard to think about from such a short description, so I've created a screencast to show it off. I TDD up a bit of code in the screencast, but it is not intended to be a good example of TDD or test design. I use a lot of stubbing and interaction assertions because I'm trying to show off Dingus' features. In real-world code, you should avoid assertions about object interaction as much as you can.

If you'd like to watch the screencast, it's available on Vimeo, but the version on the page is low quality. If you log in to Vimeo, there's a download link in the bottom right of the page. Otherwise, you can view the full size version from my blog's servers. (But please be gentle on my server's bandwidth!)



Showing 4 comments

Posted by John P. Speno at Wed Apr 8 10:23:52 2009

Super awesome. Thanks!

Would you please post your MacVIm customizations too?


Posted by Gary Bernhardt at Fri Apr 10 15:15:42 2009

My dotfiles repository (which includes my .vim directory and .vimrc file) is available on BitBucket: http://bitbucket.org/garybernhardt/dotfiles


Posted by Chris at Fri Apr 17 01:29:35 2009

So, this is awesome -- any further updates and/or documentation?


Posted by Gary Bernhardt at Thu Oct 29 22:24:37 2009

Yep - see the Dingus 0.2 release announcement at http://blog.extracheese.org/2009/10/dingus-0.2-is-released.html


Name:


E-mail:


URL:


Comment: