Select the cConvertBodyTo and cSetbody component in the Route. Right-click any
of the selected components and select Create Test
Case from the contextual menu.
The Create Route Test Case wizard
opens. Enter a name for the test case in the Name field, and the purpose and description in the
corresponding fields. Click Next.
The Define Test Skeleton details view
of the wizard opens, select the options as shown below to use a cDataset as the message producer, and a cMock to check the result. Click Finish.
The test case is then created and opened in the design workspace. Now it
looks like:
Add a cMock, cConfig and a cProcessor to
the Route by typing the name of the component directly in the design
workspace.
Configuring the test case
Cloud API Services Platform
Cloud Data Fabric
Data Fabric
Data Services Platform
ESB
MDM Platform
Qlik Talend Cloud Enterprise Edition
Qlik Talend Cloud Premium Edition
Real-Time Big Data Platform
Procedure
Double-click the cConfig component to
open its Basic settings view in the
Component tab.
In the Dependencies list, add the
xmlunit-1.6.jar, which can be obtained from the XMLUnit
website. Note that you need to add this dependency when testing XML
messages. It helps to validate the content of the XML messages against the
schema.
Double-click the cProcessor component to
open its Basic settings view in the
Component tab.
In the Import area, enter the following
code to import the external libraries:
Double-click the first cDataset component
to open its Basic settings view in the
Component tab.
In the Arguments table, the row with the
value context.input_file1 has been added automatically. Add
another row "----------------" to treat the input as one
message.
Note that when using the cDataset as the
message producer, if the input message contains multiple lines, you need to
add a line separator in the Basic settings
of the cDataset. The line separator must be
the same as the split line in the input file so that cDataset will split each message and process testing
correctly. In case there is only one multiple-line message in the input
file, you still need to set the line separator in the Basic settings of the cDataset so that it can be treated as one message. If the
line separator is not specified, each line from the input will be treated as
one message.
Double-click the first cMock component to
open its Basic settings view in the
Component tab.
Select the Simulate check box and select
the cProcessor_1 to produce the message.
Double-click the second cMock component
to open its Basic settings view in the
Component tab.
Select the Validate message bodies check
box and click the Use Inline Table option.
Click [+] to add one row in the Message table and enter
"identical" in the Value field.
In the Test cases view, click
input_file1 on the left panel and click File Browse on the right panel. Use the XML file
as shown the beginning of this example here.
For the reference_file1, browse to the XML file that contains
the expected result. Here it should
be:
In the Test Cases view, right-click the
test case name on the left panel and select Run
TestCase from the contextual menu. The execution results is
shown in the right panel.
Did this page help you?
If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!