Part 6: Event-driven message distribution between several packages¶
Objective
Event-driven message distribution between several packages which were created from the same “parent” package.
Test creation
Switch to “sender” in test case editor, select line 3 and insert a “Wait” test step with a delay of 500ms
Switch to “main” in test case editor and choose line 4
Open “react-on test step” from Test steps tab
Insert a “Time event” and specify “8” as value
Insert a “Message available” and specify “receiveLine” as value
Insert a “Return values available” and specify “sendCountOutput” as value
After that the dialog should look like in image “Test step React-On” and should be confirmed with OK
Drag parallel package call of “sender” from line 2 to line 6 (AFTER 8 ms) which ensures that the package call will not end before react-on is entered into
Drag lines 10-12 (read inbox, 2x write outbox) to line 7 (ON INBOX receiveLine)
Remove expectation for “read from inbox” (line 8)
Remove line 12 (LOOP)
Select line 11 (ON VAR) and insert the test step “break”
Save all packages and execute the main package
Test step react-on¶
Result
At the beginning, the two receiver packages are started and then wait for messages. After 8ms the sender package is started in parallel in the react-on test step. This ensures that the sender package is not yet finished when the react-on is entered into (deadlock). Now the sender package transmits a message to the main package every 500ms. The main package waits for those messages in the react-on, reads them out and communicates them to the receiver packages. As soon as the sender package is finished, the sendCountOutput variable is engaged and the ON VAR sector is entered. The IF checks whether the same number of messages was forwarded as was received, and evaluates the result. The following break quits the react-on test step.