Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Test::Unit and drb
Vassilis Rizopoulos
11/30/2006 2:06:00 PM
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.-
--
http://www.braveworl...
3 Answers
Farrel Lifson
11/30/2006 2:12:00 PM
0
On 30/11/06, Damphyr <damphyr@freemail.gr> 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 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.-
> --
>
http://www.braveworl...
>
>
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
Eric Hodel
12/1/2006 1:58:00 AM
0
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 Hodel - drbrain@segment7.net -
http://blog.se...
I LIT YOUR GEM ON FIRE!
Vassilis Rizopoulos
12/1/2006 9:54:00 AM
0
Eric Hodel wrote:
> 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?
It's not, apart from the fact that the drb server might just not be
there, so I need to recover from network errors in some way.
I am testing everything before putting it together and I am testing
without a drb connection.
Thing is in one case I make two or three calls over drb and at the
moment I can only test what happens when the first call fails, but not
what happens when the connection goes away in between calls.
The whole scenario is more of an integration test and fitting it into
Test::Unit is a bit of a push.
Cheers,
V.-
--
http://www.braveworl...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Test::Unit and drb
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password