Adding Unit Test Assertions
To add unit test assertions in
TIBCO Business Studio for BusinessWorks, follow these steps:
Before you begin
- The
UnitTestDemo.zip
file must be present in an accessible location.
- Procedure
- In
TIBCO Business Studio for BusinessWorks, on the demo project, right-click the Tests folder and select
.
The New Test File wizard displays with the Test File page.Note: You can also create a Test file in the subfolder created under the Tests folder.
- In the
New Test File wizard, change the file name to
GetDistanceUnit-NAM.bwt
and keep the Tests folder as default. Click Next. - Add the
GetDistanceUnit.bwp to the process and click
Finish.
- In the Project Explorer, open
GetDistanceUnit.bwp and click 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 the Tests tab and the created file is selected in the
Available Tests dropdown.
Note: Clicking the red cross-mark Delete selected bwt file deletes the test file permanently.
- Right-click the
Start activity and select
. Click 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.
- Right-click the
End activity and select
. Click the
Tests tab under
Properties and expand
AssertType+ and
$End-input, which is both the sides of the mapper.
- 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.
- 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.
- 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 the "boolean" data type. Drag the "metric" element from the left onto the
testInput field under Boolean and enter
false() in the
goldInput field.
- In a similar way as above, complete the mappings so that you also assert "subUnitType" and "numberOfSubUnits"
- To add a new test file, right-click the Tests folder and select
File field, add the name of the file as
GetDistanceUnit-EMEA.bwt
and click Next.
. In the
- Select
GetDistanceUnit.bwp and click
Finish.
- In the Project Explorer, open
GetDistanceUnit.bwp and click 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 the Tests tab and the
demo/Tests/GetDistanceUnit-EMEA test file is selected in the
Available Tests dropdown. If not, select it manually.
- Right-click the
Start activity and select
. Click the
Tests tab under
Properties and add EMEA in the
Content column for the
region field.
- Right-click the
End activity and select
. Click the
Tests tab under
Properties and expand
AssertType+ and
$End-input, which is both the sides of the mapper.
- Repeat steps 7, 8, 9, and 10 to set the assertions for GetDistanceUnit-EMEA with "unit", "metric", "subUnitType", and "numberofSubUnits".
The output looks as follows:To run Unit tests in TIBCO Business Studio for BusinessWorks, see Running Unit Tests in Studio.
Subtopics