Put Your TODO Items Into Your Test Case

Until now I was using a TODO file for tracking ideas and the things I still had to do. A couple of days ago, while I was working on a small ruby project, I remembered that I had to check out something after I was done with my current task, so I opened the TODO file and added a line. And then I got an idea: why use a separate file when I can use the test cases for exactly the same purpose?

These are the test cases I’m working on at the moment:

describe "page visit" do
  # more test cases

  it "should check the link to an external page" do
    # test logic
  end

  it "should check the link to an external page only once" do
    # test logic
  end
end

And I was wondering how the application should work if the content is also available locally:

describe "page visit" do
  # more test cases
end

describe "local content" do
  it "should be able to check the link to an external page"
  it "should not use the web server"
  # and the rest of the related new ideas
end

I see the following advantages so far:

  • test cases are more structured than plain TODO files
  • it is obvious what has been done and what is remaining
  • if it is easy to insert an idea into the test suite, it may mean that the idea is actually a good one

This is easy to do with ruby and rspec, but one might wonder if that is the case with other languages as well, so here is a java example:

public class PageTest {

  @Ignore
  public void shouldNotUseTheWebServerForLocalContent {
    // ...
  }
}

comments powered by Disqus