Adding Unit Test Assertions

To add unit test assertions in TIBCO Business Studio™ for BusinessWorks™, follow these steps:

Prerequisites

Procedure

  1. In TIBCO Business Studio™ for BusinessWorks™, on the demo project right-click the Tests folder and select New > Add Test File.
    The New Test File wizard displays with the Test File page.
  2. In the New Test File wizard, change the file name to GetDistanceUnit-NAM.bwt and keep the Tests folder as default. Click Next.
  3. Add the GetDistanceUnit.bwp to the process and click Finish.
  4. In the Project Explorer, open GetDistanceUnit.bwp and click on the distance.GetDistanceUnit process (green box) and select the Properties tab. Since this process is added to the Tests file, the Tests tab appears on the Process panel. Click on the Tests tab and the created file is selected in the Available Tests dropdown.
  5. Right-click the Start activity and select Add Test > Add Input. Click on the Tests tab under Properties and add NAM in the Content column for the region field.
    Note: NAM should not contain any double quotes ("").
    Note: The process does not need to be saved after adding the test inputs and assertions.
  6. Right-click the End activity and select Add Test > Add Input. Click on the Tests tab under Properties and expand AssertType+ and $End-input which is both the sides of the mapper.
  7. Drag the string|boolean|… element from the right-hand side to any element on the left hand side of the mapper underneath $End-input. The Drop wizard opens to select a data type. Select the "String" data type and click Finish.
    The testInput and goldInput fields are displayed.

  8. In the Data Source tab, drag "unit" to the testInput field. This is the value that you are evaluating in the assertion. Add miles as an input to the goldInput field.
  9. Right-click the AssertType and choose Duplicate. Right-click on Primitive-Assertion and choose Expand All. Under the second AssertType element right-click the AssertType and choose Remove Mapping. Drag the string | boolean… element from the right-hand side to any element under $End-input on the left and choose "boolean" data type. Drag the "metric" element from the left onto the testInput field under Boolean and enter false() in the goldInput field.
  10. In a similar way as above, complete the mappings so that you also assert "subUnitType" and "numberOfSubUnits"
  11. To add a new test file, right-click the Tests folder and select New > Add Test File. In the File field add the name of the file as GetDistanceUnit-EMEA.bwt and click Next.
  12. Select GetDistanceUnit.bwp and click Finish.
  13. In the Project Explorer, open GetDistanceUnit.bwp and click on the distance.GetDistanceUnit process (green box) and select the Properties tab. Since this process is added to the Tests file, the Tests tab appears on the Process panel. Click on the Tests tab and the demo/Tests/GetDistanceUnit-EMEA test file is selected in the Available Tests dropdown. If not, select it manually.
  14. Right-click the Start activity and select Add Test > Add Input. Click on the Tests tab under Properties and add EMEA in the Content column for the region field.
  15. Right-click the End activity and select Add Test > Add Input. Click on the Tests tab under Properties and expand AssertType+ and $End-input which is both the sides of the mapper.
  16. Repeat steps 7, 8, 9, and 10 to set the assertions for GetDistanceUnit-EMEA with "unit", "metric","subUnitType", and "numberof SubUnits".
    The output should look as follows:
    To run Unit Tests in TIBCO Business Studio for BusinessWorks, see Running Unit Tests in Studio.