From: Alex Young Date: 2006-09-27T21:00:43+09:00 Subject: Re: Module and Test::Unit aidy wrote: > Hi, > > Is there any way we can use test assertations in a module, or do we > always need to create a test class and inherit test unit? > > I am using assertations for GUI tests and have modules with re-usable > methods. > I'm not sure if this is what you're asking, but I do this sort of thing quite a lot: module ServiceTests def test_foo assert @thing.foo end def test_bar assert @thing.bar end end class RawTests < Test::Unit::TestCase include ServiceTests def setup @thing = Thing.new end end class XMLRPCTest < Test::Unit::TestCase include ServiceTests def setup client = XMLRPC::Client.new('localhost', '/', $port) @thing = client.proxy('thing') end end That ensures that return values and the like are correct across both native and RPC calls, without overly duplicating code. Is that what you were after? -- Alex