Ruby Unit test methods MUST* begin with “test_”

While being creative, and writing some tests in Ruby for testing a site release at the company I’m working at, I accidentally removed “test_” in front of the method name of the tests.

require "test/unit"
require 'rest-client'

class TestNewArticleLoad < Test::Unit::TestCase
  def if_site_loads_into_desktop_browser
    assert_equal(200, RestClient.get("http://www.google.com").code )
  end
end

Running this test results in a big nothing, no error message, just a shell prompt without error. It would be nice if Unit Test displayed the skipped methods, even warn, if not a single method were found in a test class.

Lesson learned, “test_” is a must, when defining methods for testing purposes, in Ruby’s Unit tests.

def test_if_site_loads_into_desktop_browser
  assert_equal(200, RestClient.get("http://www.google.com").code )
end

*:as in RFC 2119

Advertisements