On Wed, 28 Feb 2001, Aaron Hinni wrote:

> In order to speed up the test creation process, I created a simple ruby
> script to generate a test case file.  Type 'create_test ClassName' on the
> command line, and the script will create ClassNameTest.rb and fill the file
> with the necessary scaffolding to work with RubyUnit(looks like
> simpletest.rb).  This script can be built by using a HERE document and some
> simple regexps.

Hello Aaron,

let me sidetrack a bit but there's an utility which comes with RUnit
called c2t.rb (class to test mnemonic). It's not perfect, but works
for many simple cases very well.

Example:

  module FooBar

    class Foo
      attr_accessor :foo
    
      def bar
      end
    
    end

  end

command

  c2t.rb FooBar::Foo foo.rb > TestFoo.rb

creates:

  require 'runit/testcase'
  require 'runit/cui/testrunner'

  require 'foo.rb'

  class TestFooBar__Foo < RUNIT::TestCase

    def test_bar
      assert_fail("untested")
    end

    def test_foo
      assert_fail("untested")
    end

    def test_foo=
      assert_fail("untested")
    end

  end

  if $0 == __FILE__
    if ARGV.size == 0
      suite = TestFooBar__Foo.suite
    else
      suite = RUNIT::TestSuite.new
      ARGV.each do |testmethod|
        suite.add_test(TestFooBar__Foo.new(testmethod))
      end
    end
    RUNIT::CUI::TestRunner.run(suite)
  end


    - Aleksi