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("").code )

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("").code )

*:as in RFC 2119

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s