[Backgroundrb-devel] Testing worker classes

Ezra Zygmuntowicz ezmobius at gmail.com
Wed Jul 19 18:38:26 EDT 2006

On Jul 19, 2006, at 3:24 PM, James Hughes wrote:

> Hi,
> Does it make sense to test a worker class by calling
> Middleman.new_worker? Or should I just be testing the functionality in
> the do_work method, with, say, a mock object. This seems like a really
> ugly DRY violation: you'd need to keep the code in the mock and the
> real worker in sync.
> That's the philosophical half of my question. In fact, until someone
> tells me why I shouldn't, I am trying to call new_worker from a test
> method in the test class generated by the worker generator. I'm
> getting
> NoMethodError: undefined method `[]' for #<DRb::DRbUnknown:0xb72c7128>
> I note in another thread that this  is due to DRbundumped not being
> included in the class that is causing the error. I took this to mean
> that I need "include DRbundumped" in my test class, but that didn't
> work. I'm not sure where else I should include it. I know that
> eventually I'll need to put it in the non-test class that calls
> new_worker, but I'm not there yet. Is testing workers just a
> non-starter?
> Here's the test method:
>   def test_task_is_triggered
>     job_key = MiddleMan.new_worker :class => :task_checker_worker,
>        :args =>  tasks(:should_be_triggered)
>     @job_keys << job_key
>    #     ...assertions go here...
>   end
> thanks,
> jh
> --  
> James Hughes

Hey James-

	Yeah I have some code for a better test harness that I need to get  
working correctly and release. The best way I have come up with is to  
create an additional config file for test mode that connects to the  
test db. Then you have a rake wrapper for your tests that starts the  
drb server in test mode when your tests fire up. Because there needs  
to be a good way to test things from end to end through the  
MiddleMan. I am open for suggestions on a better test harness. I am  
just very busy this week so I won't have time until at least the  
weekend to get something new released.


P.S. I would love a patch for a better test harness if any one comes  
up with one ;)

More information about the Backgroundrb-devel mailing list