Unit Testing

Unit testing in TIBCO BusinessWorks Container Edition consists of verifying whether individual activities in a process are working as expected. While you can run the unit tests on processes any time during the development cycle, testing the processes before you push the application to the production environment may help you to identify issues earlier.

This section explains how to use the Maven plugin and its features to achieve unit testing of TIBCO BusinessWorks Container Edition projects.

Following are the sample projects provided with the TIBCO BusinessWorks Container Edition application:

  • tibco.bw.UT.sample.MainProcessWithUnitTestDemo.zip: This unit test sample demonstrates the support for mock inputs to the process starter, along with assertions and mocking for main process activities, as well as for REST and SOAP services.

  • tibco.bw.UT.sample.UnitTestDemoProject.zip: This unit test sample demonstrates the support of mock inputs for the subprocess starter, along with assertions and mocking for subprocess activities.

  • tibco.bw.UT.sample.Calculator.module.zip: Sample shows the use case of implementing unit test cases in the Shared Module of your application.

Following are the details of the processes in the sample projects:

tibco.bw.UT.sample.MainProcessWithUnitTestDemo:

  • MainProcessWithProcessStarterMocked: Shows assertion support in the main process along with mocking support on process starter

  • RESTServicBindingeMocked: Shows mocking support on the REST Service binding

  • SOAPServiceBindingMocked: Shows mocking support on the SOAP Service binding

tibco.bw.UT.sample.UnitTestDemoProject:

  • SubProcesswithActivityAssertion.bwp: Shows mocking support and Activity Assertion in a subprocess

  • SubProcessWithPrimitiveAssertion.bwp: Shows mocking support and Primitive Assertion in a subprocess

tibco.bw.UT.sample.Calculator.module:

  • Calculator: This process invokes calculation operations based on input received from the HTTPReceiver. It demonstrates support for mocking the HTTPReceiver and Primitive assertion on the "cube" (a call process activity).

    In the Shared Module, you can find the following processes:

    • Division: This process provides inputs (number 2 and number 0) to trigger a divide-by-zero exception, simulating a mock fault. These values can be modified to test different scenarios.

    • Cube: This process provides input (number 8) for the cube operation and verifies the result of the "end" activity using an activity assertion.

    • Multiply: This process provides inputs (number 2 and number 3) using an "input XML file" for multiplication and verifies the result of the "end" activity using an activity assertion with a reference to a gold input file on the "end" activity.

    • Square: This process provides input (number 2) using an "input XML file" for squaring and verifies the result of the "end" activity using a primitive assertion.