Anybody have any tips to share about unit testing code that uses drb?
My problem is, I can test all the the logic in smaller chunks, but as
soon as I integrate everyhting and have code in place that verifies and
recovers from connection errors I need to at least establish that drb
connection.
How would I go about doing this in a unit test environment?
Getting a mock drb server in a thread and launching it in setup seems
too clunky.
Any brilliant ideas?
Cheers,
V.-
On 30/11/06, Damphyr [email protected] wrote:
Any brilliant ideas?
Cheers,
V.-
http://www.braveworld.net/riva
This is how I’ve done it though if anyone has better solutions I’d be
glad to hear them:
require ‘drb’
require ‘test/unit’
class Counter
def initialize;@counter = 0;end
def count;@counter+=1;end
def self.start
DRb.start_service(“druby://localhost:9000”,self.new)
end
def stop
DRb.stop_service
end
end
class TC_Counter < Test::Unit::TestCase
def setup
@t = Thread.new do
Counter.start
end
@counter = DRbObject.new_with_uri(“druby://localhost:9000”)
end
def teardown
@counter.stop
@t.exit
end
def test_count
assert_equal(1,@counter.count)
assert_equal(2,@counter.count)
assert_equal(3,@counter.count)
end
end
On Nov 30, 2006, at 0605 , Damphyr wrote:
Anybody have any tips to share about unit testing code that uses drb?
My problem is, I can test all the the logic in smaller chunks, but
as soon as I integrate everyhting and have code in place that
verifies and recovers from connection errors I need to at least
establish that drb connection.
How is multiprocess operation (DRb dispatched) different from
multithreaded operation (method calls) for your program?
–
Eric H. - [email protected] - http://blog.segment7.net
I LIT YOUR GEM ON FIRE!