[jboss-user] [jBPM] - jBPM JUnit tests are failing
Michael Wagner
do-not-reply at jboss.com
Wed Jul 20 05:15:29 EDT 2011
Michael Wagner [http://community.jboss.org/people/michael.wagner] created the discussion
"jBPM JUnit tests are failing"
To view the discussion, visit: http://community.jboss.org/message/616326#616326
--------------------------------------------------------------
Hi,
I have downloaded the junit tests from:
http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.1.0.Final/jbpm-5.1.0.Final-examples.zip/download http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-5.1.0.Final/jbpm-5.1.0.Final-examples.zip/download
First: big thank you for providing so many unit tests! Makes is absolutly clear how to use the api.
Running JBPM2UnitTests.java gives me always one failure in testTimerStart:
junit.framework.AssertionFailedError: expected:<5> but was:<4>
"Correcting" the value to 4 gives a failure in testTimerStartCron:
junit.framework.AssertionFailedError: expected:<5> but was:<6>
"Correcting" the value here to 6 gives no more failures any more.
public void testTimerStartCron() throws Exception {
KnowledgeBase kbase = createKnowledgeBase("BPMN2-TimerStartCron.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
final List list = new ArrayList();
ksession.addEventListener(new DefaultProcessEventListener() {
public void afterProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
Thread.sleep(500);
for (int i = 0; i < 5; i++) {
ksession.fireAllRules();
Thread.sleep(1000);
}
assertEquals(6, list.size());
}
public void testTimerStart() throws Exception {
KnowledgeBase kbase = createKnowledgeBase("BPMN2-TimerStart.bpmn2");
StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
final List list = new ArrayList();
ksession.addEventListener(new DefaultProcessEventListener() {
public void afterProcessStarted(ProcessStartedEvent event) {
list.add(event.getProcessInstance().getId());
}
});
Thread.sleep(250);
assertEquals(0, list.size());
for (int i = 0; i < 5; i++) {
ksession.fireAllRules();
Thread.sleep(500);
}
assertEquals(4, list.size());
}
Besides that I cannot understand the values by reading the code: what I definitively do not understand is: how can somebody write tests depending on a "Thread.sleep"? Are there no events one could wait for? This gives a situation which is not deterministic! This is because time is not processor time.
Please tell me how the junit tests in these cases could be re-written in a deterministic way.
We are in an automotive area and cannot affort to run software which can not be testet in a deterministic way.
Michael
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/616326#616326]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110720/4acbc11c/attachment.html
More information about the jboss-user
mailing list