이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 15. Test Driven Development for Workflow
15.1. Introducing Test Driven Development for Workflow 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Read this chapter to learn how to use JUnit without any extensions to unit test custom process definitions.
Keep the development cycle as short as possible. Verify all changes to software source code immediately, (preferably, without any intermediate build steps.) The following examples demonstrate how to develop and test jBPM processes in this way.
Most process definition unit tests are execution-based. Each scenario is executed in one JUnit test method and this feeds the external triggers (signals) into a process execution. It then verifies after each signal to confirm that the process is in the expected state.
Here is an example graphical representation of such a test. It takes a simplified version of the auction process:
Figure 15.1. The auction test process
Next, write a test that executes the main scenario:
15.2. XML Sources 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Before writing execution scenarios, you must compose a
ProcessDefinition
. The easiest way to obtain a ProcessDefinition
object is by parsing XML. With code completion switched on, type ProcessDefinition.parse
. The various parsing methods will be displayed. There are three ways in which to write XML that can be parsed to a ProcessDefinition
object:
15.2.1. Parsing a Process Archive 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
A process archive is a ZIP file that contains the process XML file, namely
processdefinition.xml
. The jBPM Process Designer plug-in reads and writes process archives.
static ProcessDefinition auctionProcess = ProcessDefinition.parseParResource("org/jbpm/tdd/auction.par");
static ProcessDefinition auctionProcess =
ProcessDefinition.parseParResource("org/jbpm/tdd/auction.par");
15.2.2. Parsing an XML File 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
To write the
processdefinition.xml
file by hand, use the JpdlXmlReader
. Use an ant
script to package the resulting ZIP file.
static ProcessDefinition auctionProcess = ProcessDefinition.parseXmlResource("org/jbpm/tdd/auction.xml");
static ProcessDefinition auctionProcess =
ProcessDefinition.parseXmlResource("org/jbpm/tdd/auction.xml");
15.2.3. Parsing an XML String 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
Parse the XML in the unit test inline from a plain string: