On Thu, Oct 07, 2010 at 05:09:34PM -0700, Pat Gannon wrote:
>
> I'm having trouble creating repeatable automated tests for my
> workflows.  Are there any examples of writing tests (RSpec or other)
> to verify the behavior of a particular workflow?
> 
> In particular, I want to test what work items have been created part-
> way through a workflow, so engine.wait_for doesn't seem to be a good
> fit (since it waits for the whole workflow to complete), so I had to
> insert a "sleep" in my test, which makes it slow.  My test also seems
> to be a bit brittle (fails sporadically).

Hello Pat,

welcome to the ruote mailing list.

You could have a look at the test suite :

  http://github.com/jmettraux/ruote/tree/ruote2.1/test/functional/

There is also ruote-cukes, which is unfortunately not yet complete :

  http://github.com/jmettraux/ruote-cukes

(IIRC it uses a sleep as well).

With the functional test suite, the pattern is :

( http://gist.github.com/616159 )

---8<--
require 'rubygems'
require 'ruote'

pdef = Ruote.process_definition do
  sequence do
    alpha
    bravo
  end
end

engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new))

engine.register do
  catchall Ruote::StorageParticipant
end

#engine.noisy = true

wfid = engine.launch(pdef)

engine.wait_for(:alpha)

wi = engine.storage_participant.first

puts "this workitem reached alpha :"
p wi

engine.storage_participant.reply(wi)

engine.wait_for(:bravo)

wi = engine.storage_participant.first

puts "this workitem reached bravo :"
p wi

engine.storage_participant.reply(wi)

engine.wait_for(wfid)

puts "process instance over"
--->8---

Engine#wait_for() when receiving symbols waits for participant to receive 
workitems.

Please note the engine.noisy = true trick if you want to know what the engine 
is doing.


I'd be glad to help fixing the brittleness of your test. If it's still brittle 
after adopting engine.wait_for(:participant_name), please tell me.


Best regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to