Icon

02a Unit testing - Exercise

This workflow showcases the aspects of building the unit test. The workflow:
Step 1. Build the unit test

  1. Read the input and output golden tables with the Table Reader nodes, use the path relative to the current workflow. Files are located at:

    • ../../../../../data/Golden Data/Unit_test_Input_data.table

    • ../../../../../data/Golden Data/Unit_test_Output.table

  2. Drag the shared component Summarize Timestamp-Hour from the Components folder and connect it to the input golden table

  3. Reset the domain of the component Summarize Timestamp-Hour output with the Domain Calculator

  4. Reset the domain of the output golden table with the Domain Calculator node

  5. Compare the actual component output with the expected result. Use the Table Difference Finder node (use the tables with the reset domains)

    • Select Different values as the Fail option. The node then fails when the input and output tables have different values

    • Connect the flow variable output of Table Difference Finder node to the Variable Creator node for the main (success) branch and to the Active Branch Inverter node for the alternative (failure) branch


Component Testing
Step 2. Export testflow status and metadata (e.g., to the testflow report workflow)

  1. Select required the flow variables required in the testflow report in the Variable To Table Row node:

    • Status: Indicates the final state of the testing process

    • FailingNodeStackTrace: Error message

    • FailingNodeMessage: Explains the cause of the failure

    • FailingNode: Identifies the nodes facing issues during testing

    • execution-data-time: Timeframe of when the testing occurred

    • context.workflow.name: Name of the workflow being executed

    • context.workflow.user: User responsible for running the test

  2. Export testflow status and metadata

    • Send the table from the Column Resorter node to the Workflow Service Output node


Learning objective: Learn how to build a unit test for a shared component


Workflow description: This workflow showcases the aspects of building the unit test. The workflow:

  • Reads the input golden table and provides it to the component being tested,

  • Compares the component output against a golden output data,

  • Enables sending the test status along with the testflow metadata to a caller workflow (e.g., testflow report)


You'll find the instructions to the exercises in the yellow annotations.

Part 1 - Preparing a data pipeline for deployment

Exercise 02a Unit testing

Summarize Timestamp-Hour
Status in case ofSuccess
Variable Creator
Column Renamer
Column Resorter
Active Branch Inverter
Workflow Metadata
Status in case of Failure
Variable Creator
Domain Calculator
Table Difference Finder
Variable to Table Row
Domain Calculator
Golden dataInput
Table Reader
Golden dataOutput
Table Reader
Try (Variable Ports)
Export status and metadata
Catch Errors (Var Ports)
Workflow Output

Nodes

Extensions

Links