---
title: "从jbpm的代码看单元测试"
author: "hongsoft"
date: "2005-01-15T20:40:00Z"
tags: ["JBPM", "单元测试"]
slug: "jbpm"
draft: false
lastmod: "2005-01-15T20:40:00Z"
id: 287500
url: "https://hongsoft.iteye.com/blog/287500"
---

在jbpm中,我们可以在很多地方看到这样的测试代码:  
pd = new ProcessDefinition( new String\[] {  
            "start-state start",  
            "state first",  
            "state second",  
            "state third",  
            "end-state end"  
          }, new String\[] {  
            "start --left--&gt; first",  
            "start --right--&gt; second",  
            "first --&gt; third",  
            "second --&gt; third",  
            "third --&gt; end"  
          });  
这个方法的第一个参数是流程定义中的node数组,第二个参数是transition的表达  
如: second --&gt; third表示一个从second Node到third Node的transition  
    start --left--&gt; first 表示一个从start到first的transition,它的名称为left  
实现这种串的解析的代码在ProcessFactory.cutTransitionText()方法中,而这个方法完全是为了测试而  
写的,由此我们可以看出单元测试的重要性.