How do I create a TestSuite

This code used to work under 1.6.8 with Test::Unit 0.1.8:

0rasputin@lb:stickyfingers$ cat test/all.rb
#! /usr/local/bin/ruby -w

require ‘test/unit’

require 'test/chaintest’
require 'test/chunkertest’
require ‘test/filestoretest’

class Daddy < Test::Unit::TestSuite
self << ChainTest.new
self << ChunkerTest.new
self << FilestoreTest.new
end

0rasputin@lb:stickyfingers$

(The classes listed are just bog standard
class ChunkerTest < Test::Unit::TestCase’ affairs).

It now gives errors under CVS Ruby - looks like a change in the TestCase
constructor. How do I create a testsuite now?

0rasputin@lb:stickyfingers$ /usr/local/bin/ruby -v
ruby 1.8.1 (2003-11-21) [i386-netbsdelf]
0rasputin@lb:stickyfingers$ /usr/local/bin/ruby test/all.rb
test/all.rb:10:in initialize': wrong number of arguments(0 for 1) (ArgumentError) from test/all.rb:10:innew’
from test/all.rb:10

···


BASIC, n.:
A programming language. Related to certain social diseases in
that those who have it will not admit it in polite company.
Rasputin :: Jack of All Trades - Master of Nuns

This code used to work under 1.6.8 with Test::Unit 0.1.8:

Are you sure? I don’t think creating a TestCase without a test to run
has ever worked. I think what you want is:

0rasputin@lb:stickyfingers$ cat test/all.rb
#! /usr/local/bin/ruby -w

require ‘test/unit’

require ‘test/chaintest’
require ‘test/chunkertest’
require ‘test/filestoretest’

class Daddy < Test::Unit::TestSuite
self << ChainTest.new
self << ChunkerTest.new
self << FilestoreTest.new
self << ChainTest.suite
self << ChunkerTest.suite
self << FilestoreTest.suite
end

It now gives errors under CVS Ruby - looks like a change in the
TestCase
constructor. How do I create a testsuite now?

As I said, I don’t think the code above would have ever worked. You
might like to know, though, that you don’t have to create your own
TestSuite; try this:

#! /usr/local/bin/ruby -w

require ‘test/unit’

require ‘test/chaintest’
require ‘test/chunkertest’
require ‘test/filestoretest’

I think you’ll find that’s all you need.

HTH,

Nathaniel

<:((><

···

On Dec 1, 2003, at 10:26, Rasputin wrote:

This code used to work under 1.6.8 with Test::Unit 0.1.8:

Are you sure? I don’t think creating a TestCase without a test to run
has ever worked. I think what you want is:

Hmm,looks like you might be right. It definitely worked with no
errors last week, possibly under the CVS code?

0rasputin@lb:stickyfingers$ cat test/all.rb
#! /usr/local/bin/ruby -w

require ‘test/unit’

require ‘test/chaintest’
require ‘test/chunkertest’
require ‘test/filestoretest’

class Daddy < Test::Unit::TestSuite
self << ChainTest.new
self << ChunkerTest.new
self << FilestoreTest.new
self << ChainTest.suite
self << ChunkerTest.suite
self << FilestoreTest.suite
end

It now gives errors under CVS Ruby - looks like a change in the
TestCase
constructor. How do I create a testsuite now?

As I said, I don’t think the code above would have ever worked.

God knows where I got that from then! I cut and pasted from somewhere…

might like to know, though, that you don’t have to create your own
TestSuite; try this:

#! /usr/local/bin/ruby -w

require ‘test/unit’

require ‘test/chaintest’
require ‘test/chunkertest’
require ‘test/filestoretest’

Thats great , thanks.

···

On Dec 1, 2003, at 10:26, Rasputin wrote:


Disclaimer: “These opinions are my own, though for a small fee they be
yours too.”
– Dave Haynie
Rasputin :: Jack of All Trades - Master of Nuns

This code used to work under 1.6.8 with Test::Unit 0.1.8:
[snip]
class Daddy < Test::Unit::TestSuite
self << ChainTest.new
self << ChunkerTest.new
self << FilestoreTest.new
self << ChainTest.suite
self << ChunkerTest.suite
self << FilestoreTest.suite
end

How about a ‘test_all.rb’ which simply just appends all testsuites it
finds in current dir ?

expand -t2 test_all.rb
require ‘test/unit’

class TestAll
def TestAll.suite
suite = Test::Unit::TestSuite.new
Object.constants.sort.each do |k|
next if /^Test/ !~ k
constant = Object.const_get(k)
if constant.kind_of?(Class) &&
constant.superclass == Test::Unit::TestCase
suite << constant.suite
end
end
suite
end
end

if FILE == $0
Dir.glob(“test_*.rb”).each do |file|
require “#{file}”
end
require ‘test/unit/ui/console/testrunner’
Test::Unit::UI::Console::TestRunner.run(TestAll)
end

···

On Tue, 02 Dec 2003 02:34:02 +0900, Rasputin wrote:

On Dec 1, 2003, at 10:26, Rasputin wrote:


Simon Strandgaard

How about a ‘test_all.rb’ which simply just appends all testsuites it
finds in current dir ?

Sweet! Thanks a lot!

···

expand -t2 test_all.rb
require ‘test/unit’

class TestAll
def TestAll.suite
suite = Test::Unit::TestSuite.new
Object.constants.sort.each do |k|
next if /^Test/ !~ k
constant = Object.const_get(k)
if constant.kind_of?(Class) &&
constant.superclass == Test::Unit::TestCase
suite << constant.suite
end
end
suite
end
end

if FILE == $0
Dir.glob(“test_*.rb”).each do |file|
require “#{file}”
end
require ‘test/unit/ui/console/testrunner’
Test::Unit::UI::Console::TestRunner.run(TestAll)
end


Simon Strandgaard


All my friends and I are crazy. That’s the only thing that keeps us sane.
Rasputin :: Jack of All Trades - Master of Nuns