Skip to content

Steps To Add MockFault

Sujata edited this page Feb 20, 2020 · 3 revisions

images/writeFileFaultMock.xml


Mocking Support to BW Activities in BusinessWorks

Introduction

This page provides steps to add mock Fault for BW activities in BusinessWorks 2.5.2 with the Maven Plugin- 2.6.0. User can also mock faults thrown by activities so that they can test their exception handling logic and test all the transitions. Currently, Mocking Feature doesn't support the main process. They only mock faults of the activities from sub-processes.

Pre-requisites

• Apche Maven: https://maven.apache.org/download.cgi

• BusinessWorks Maven Plugin with version 2.6.0 should be installed. Please download the BW6-Maven-Plugin 2.6.0 from here: https://github.com/TIBCOSoftware/bw6-plugin-maven/releases

• Activities to be mocked should be present in sub-process where sub-process should be under Unit testing.

• Generate valid Mock Fault XML file. Please refer section "Steps to Generate the Mock Fault File" https://github.com/SujataDarekar/bw6-plugin-maven/wiki/Steps-To-Add-MockFault#steps-to-generate-the-mock-fault-file

Adding Mock Fault to an Activity

This section assumes that you have already created the demo project with subprocess which has the activities whose faults to be mocked.

  1. Right-click on module project and select New->Tests Folder. This will add the "Tests" folder in the module project.

  1. Right-click on the Tests folder in Project Explorer and choose New -> Add Test File. Change the Test File name if needed and hit Next which will show the wizard with a list of Sub-Processes. Select the subprocess having the activities whose faults to be mocked.

  1. Right-click on the activity to mock fault and select an option "Add Mock Fault To Activity".

  1. New "Tests" tab will get added in the property section of activity after selecting the above option. This tab has "File Selector" to select the mock fault File. Select the mock fault data file using File Selector. user can provide the relative mock fault file in "Mock Fault File" field

Running the Unit Tests in Business Studio

Please refer below link : https://github.com/TIBCOSoftware/bw6-plugin-maven/wiki/Steps-To-Add-MockOutput#running-the-unit-tests-in-business-studio

Steps to Generate the Mock Fault File

  1. Run the application in debug mode from the Business studio.
  2. Select the "Fault" tab from the Job Data for an faulted activity for which we need to generate the mock fault file.
  3. Right click on the activity exception tag in Fault tab and copy the data by selecting the option "Copy Variables" as shown in below image:

  1. Paste the copied data into the XML file

  1. Please check attached file for more details.

    writeFileFaultMock.xml

Limitations

  • Only sub-processes can be used for unit testing – top-level processes aren’t supported
  • Process Starter and SignIn activities don't provide the Mocking Support.
  • BusinessWorks needs to be installed on the same server where the tests are to be run
  • Unit Tests can currently only be invoked via Maven

Clone this wiki locally