When you create a new BPEL process from JDeveloper, you always have an empty Test Suites folder in the Integration Content folder. This is where will be all the tests.
Basic concepts :
- test suite contains several tests (I recommend to have different test suite for each kind of tests you could have)
- baseline is a common base for different tests. Each test can import a baseline to get a global behaviour (the create instance inbound message for example)
Let's create a very simple sync BPEL process (it just copies 'OK' into the output variable). This process is called SimpleTest (source code available here).
A simple test for a simple process
Now we have our BPEL process, we want to test if our process replies 'OK' or not.
So just create a new test suite and then a new test.
You should have a new designer/source window opened. This is the test editor.
From there, you can emulate messages (inbound and outbound), add some asserts, etc.
We only want to check if our simple process replies 'OK'.
1. Emulate the inbound message
In each test, you must emulate the first inbound message (ie on the create instance invoke). This is a very common use for a baseline. Double click on the invoke activity > Emulate tab> Emulate message and then enter the content of the message.
2. Add assert activities
Then we are able to add assert activities on each BPEL activity which manipulates / transfers some variables (assign, invoke, receive, scope). Double click on our assign > Asserts tab > Create > Value Assert :
- browse the output variable and select the result element
- Comparaison method : String (this is the type of your element)
- Expected value : OK
- Error message : process is corrupted
- Fatal : uncheck the box ! (This is really important. If not and if the test failed, you cannot get the results. The box is checked by default)
3. Deploy the test
The BPEL process must be already deployed in order to realize this step.
In the deploy menu in JDev, you have the BPEL Process Deployer but also the BPEL Test Deployer. Select this test deployer, and check the test suite, your test and your BPEL server domain. And just deploy it.
4. Running the test
The simplest way to run the test is throught the BPEL console.
In all of the tabs that you have (manage, initiate, descriptor, WSDL, etc.) when you click on a BPEL process (not a BPEL instance), you also have the testsuites tab which is usefull to run tests & test suites. Just go in this tab and check your test suite with your test.
And execute tests !
5. Reporting
You now have a complete report of the state (passed or failed) of all your tests inside your different test suites.
I particulary like the % of process coverage by the unit tests (like a cobertura report). To get a 100%, you must cover all the different paths in your BPEL process by tests (including catchs, onAlarms, etc.).
You can even see the flow of the run BPEL testing instance.
You can modify your BPEL process and have a 'KO' instead of the 'OK'. You'll need to reploy your tests as well. You should get something like that :
Source code of tests here.
Happy new year !