Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

Enterprise intelligence with prediction markets

Find out what your team, colleagues and partners really know about the future — and leverage their knowledge to improve business decisions.

I'm the founder of Planypus, the place to share your plans!

Archives

Contact

Reach me at yan at pritzker.ws

Humanized test coverage

Posted 14 August 2006 @ 9pm | Tagged software, thoughts


Submit to HN

Rails still doesn’t offer a very good test coverage tool. Sure there’s rcov but it’s painfully slow, and I found it to be quite inaccurate, though to be fair I have only played with it a little bit. The other day I stumbled across a cool way to do test driven development with rails, right from The Wiki. The premise is that you name your tests in the form test_should_do_something_cool, and the have a rake task that harvests test names from each controller and prints them as english sentences. The task can be found on the wiki page so I won’t repeat it here, but what I did add was a method to my webapp that invokes the rails task to give me a coverage report right from the web:


def coverage
output = `cd #{RAILS_ROOT}; rake agiledox`.gsub!("- truth","<span style='color:red'>default truth method</span>")

render :inline => "<pre>" + output + "</pre>"
end

What i’m doing there is highlighting in red any controller that still has the default “test truth” method in it so that it stands out. The output looks something like this:


groups_controller should:
- successfully create group with creator as member
- send email and create pending membership when user wants to join restricted group
- add user when pending membership is approved by group creator

Not quite real test coverage but at least it gives you a sense of what kind of test you have.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment