process testing

A few notes about testing/specing process definitions

the bare way

Testing a process definition without a test framework. Useful when demonstrating a ruote feature or making sure that this feature works for a person (I use this way all the time on the mailing list).

            require 'rubygems'
            require 'ruote' # gem install ruote
            engine =
              # an engine + worker combo with an in-memory storage,
              # ideal for process definition testing
            #engine.noisy = true
              # when the engine/worker is not replying, uncomment this and restart the
              # test, it the worker will then explain its activity in yellow chars
              # in your console
            engine.register do
            pdef = Ruote.process_definition do
            wfid = engine.launch(pdef, { 'colour' => 'blue' })
              # launching an instance of pdef, with a workitem whose initial fields
              # contain 'colour' => 'blue'
              # we keep the process instance id in the variable 'wfid' (workflow
              # instance id)
              # waiting for a participant name as a symbol, this call will block until
              # a workitem was delivered to participant 'alpha'
            workitem = engine.storage_participant.first
              # grab the workitem from the storage participant
            #workitem.fields['colour'] = 'red'
              # maybe alter the payload of the workitem
              # hands back the workitem to the storage participant, it will erase it
              # and hand it back to the engine so that the flow may resume
              # waiting for flow to pop a workitem up at the next step
            workitem = engine.storage_participant.first
              # grab the workitem from the storage participant
              # wait for our process to terminate (or to issue an error)
            raise "process not over" if engine.process(wfid)

classical way


cucumber way

ruote-cukes is a set of step definitions for testing ruote process definitions from Cucumber, unfortunately, it’s not complete.