Tuesday 16 June 2009

Looking good, feeling bad

What do you feel about the following line of output?

20 tests, 20 assertions, 0 failures, 0 errors

Happy, sad or nervous?

Well Ruby helpfully generates the scaffolding for tests whenever you create a new controller. They look like this:

require 'test_helper'

class HomeControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

So I have just tested that true does really equal true, twenty times. That warm fuzzy feeling is changing into a nervous tick. I propose a new rule, tests should actually test something or delete them.

No comments:

Post a Comment