[jbpm-dev] [Design of JBoss jBPM] - Test Driven Process Development conveniences

kukeltje do-not-reply at jboss.com
Wed Dec 10 05:20:20 EST 2008


More and more, I'm becomming a fan of this. But my tests quickly become unreadable by anyone that is not kind of familiar with some jBPM internals/api things. 

I therefore started to create more and more convenience methods in an class that extended AbstractDBTestcase. Things like deploying processes (to prevent things Bernd ran into), testing if tasks exist, are assigned to a specific actor, a specific number of tasks exist etc... all in the context of a processinstance. 

Things I came up with until now are

For each method in the class under test:
- Deploy a processdefinition that has the same filename and name as the method itself
- If not exists deploy a process that has the same filename and name as the class under test
- Start an instance of it and make sure it is running and usable
- At the end, clean up all the 'leftovers'

When working with a processinstance I have the following assertion methods:
- assertTaskExists(String taskname)
- assertTaskExistsForActor(String taskname, String expectedActorId)
- assertTaskListLength(int expectedTasklistLength)
- assertTaskHasEnded(String taskname)
- assertProcessHasEnded()
- assertVariableValue(String variableName, Object expectedValue)
- assertNodeActive(String nodeName)

To prevent the need to use more low level jBPM classes, I choose to use strings. Methods that  do use them could ofcourse be introduced as well.

Additional convenience methods that might be in the api eventually are:
- endTask(String taskName);
- endTask(String taskName, String transition);
- assignTask(String taskName, String actorId);
- unassignTask(String taskName); // same as assignTask with actorId being null or empty string
- setVariable(String variableName, Object variableValue)


More methods could be added, but these are the ones I encountered most. I'm currently cleaning up my class before posting it on my blog but hope to get some feedback in advance about this. I also want to add it to the jBPM codebase since it makes tests a lot more easier to read.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195522#4195522

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4195522



More information about the jbpm-dev mailing list