Topic: Why No tests were specified?

In my test:

require File.dirname(__FILE__) + '/../test_helper'

class TestingSiteTest < Test::Unit::TestCase
  fixtures :testing_sites

  def creates_a_valid_testing_site
     c = create_valid_testing_sites
     assert c.valid?
     def create_valid_testing_site(options = {})
        :name => "Hill Research",
        <ya-da, ya-da>

I get a "No tests were specified" failure.

RubyMate r8136 running Ruby r1.8.6 (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby)
>>> testing_site_test.rb

Loaded suite /Users/karl/passiton/test/unit/testing_site_test
Finished in 2.137531 seconds.

  1) Failure:
No tests were specified.

1 tests, 1 assertions, 1 failures, 0 errors


Re: Why No tests were specified?

try renaming your test to test_creates_a_valid_testing_site

Re: Why No tests were specified?

So all tests must begin with "test"?

Re: Why No tests were specified?

Try changing:

def creates_a_valid_testing_site

def test_creates_a_valid_testing_site

I believe UnitTest requires all tests to be performed to begin with test_, that way you have the freedom of defining other helper methods with other names that aren't actually tests.

Re: Why No tests were specified?

Wow, didn't know that.

As I quietly review a half dozen of my Rails apps...

Re: Why No tests were specified?

Interestingly enough when I first started using TestUnit (before I got into RSpec) I had a real headache for a while with a super confusing stacktrace that eventually led me to notice I had another class (or method can't remember which now) defined elsewhere in my project that began with "test_" and TestUnit was flipping out because of it.  I had to rename that item in order to keep using TestUnit.