-
Notifications
You must be signed in to change notification settings - Fork 80
Steps To Add MockOutput
This document provides steps for adding mocking support for BW activities in BusinessWorks 2.4.4 with the Maven Plugin. User can skip execution of activity(usually activities that are based on external service) whose process is under Unit Testing. Mocking support functionality is required mainly for the BW activities that are based or dependent on some external Cloud Service or Database systems which are eventually under Unit Testing. To execute Unit Testing successfully on processes that contain these BW activities, we need to mock these BW activities. Now a dummy output can be added to mock activities that can be used in Unit testing for successful execution.
Currently, Mocking Feature doesn't support the main process – they only mock the activities from sub-processes.
• Apche Maven: https://maven.apache.org/download.cgi
• BusinessWorks Maven Plugin with version 2.2.0 should be installed. Please download the BW6-Maven-Plugin 2.2.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 Output XML file. Please refer to the Output File Generation section to generate the Mock Output file.
This section assumes that you have already created the demo project with subprocess which has the activities to be mocked.
- Right-click on module project and select New->Tests Folder. This will add the "Tests" folder in the module project.
- 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 to be mocked.
- Right-click on the activity to mock and select an option "Add Mock To Activity".
- 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 Output File. Select the output file using File Selector.
- Now the user can provide the relative mock output file in "Mock Output File" field. User need to keep mock output file in "Tests" folder of the BW project. User can create separate folder for mock files under "Tests" folder The relative path will have the value like "Tests/fileName.xml". It's mandatory to provide the "Tests" folder name also in relative path. Note: This feature will be available with BW Maven Plugin 2.5.0
- In Business Studio, right-click on .application and choose "Generate POM for Application". Set Tibco Home as the TIBCO Home for your BW installation with no trailing slash, e.g. C:\tibco\bw651 for Windows. Set BW Home as the relative path to the version-specific BW folder under TIBCO Home (with a leading slash and no trailing slash), e.g. \bw\6.5 for Windows. Hit Finish:
- This will, now, convert the existing projects to Maven type and add a new project called *.application.parent and create pom.xml files in all projects:
- Right click on the parent project and run "test" goal
- Run the application in debug mode from the Business studio.
- Select the "Output" tab from the Job Data for an activity which we need to generate the mock output file for
- Right click on the activity Name in Output tab and copy the data by selecting the option "Copy Variables" as shown in below image:
- Paste the copied data into the XML file and add opening and closing tag for variables
- Services like REST and SOAP can have multiple variables. So in Job Data, the output will be shown for multiple variables. In this case, append the file for each variable data.
- 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
Getting started
- Steps to Mavenize BW Application
- Building applications for BWCE
- EAR deployment with Config File
- Shared Modules with Maven
- Add Process Diagram in EAR
- BW Design Utility Goals
- CI/CD using Jenkins
- Custom XPath Function
- Deploy Shared Module on Remote Repository
- TCI Deployment using Maven Plugin
Unit Testing
- Primitive Assertion
- Activity Assertion
- Activity Assertion with Gold Input File
- Mock Output
- Mock Fault
- Test Suite
- Plugin Properties
Help & Contribute