# Testing
Testing in Kumologica is a crucial aspect of ensuring the reliability, resilience, and correctness of your flows. It is a fundamental practice for building robust and maintainable Kumologica flows.
Kumologica allows you to perform end-to-end integration tests (flow testing), as well as unit testing (subflow testing).
There is two convenient ways to test within Kumologica: a command-line interface (CLI), and within the intuitive Kumologica Designer. This dual approach empowers you to seamlessly integrate tests into your CI/CD pipeline while maintaining a rapid and interactive development experience.
TIP
Kumologica Designer is running always on hot-deployment during local development, hence, there is no need to deploy before running the test cases.
# Defining a TestCase
A test case is defined as one TestCase
or HTTPTestCase
type nodes as an entry point, followed by one or more Assertion
type nodes, and ended with a TestCaseEnd
node.
# Integration Testing
Integration testing in Kumologica involves the use of TestCase
or HTTPTestCase
nodes to send HTTP requests to the logic flow.
The response coming from the flow will be passed to each Assertion
node in a sequential manner. The final report will be presented, either on the terminal via CLI or seamlessly integrated into the test runner within the designer.
The following image illustrates a typical example of integration testing:
The HTTPTestCase
node is a convenient node for sending these requests, while the TestCase
node specifically dispatches POST only requests. This node proves particularly valuable when dealing with non API Gateway events, such as functions triggered by AWS S3 or AWS DynamoDB events.
The diagram below captures the outlined integration test process:
# Unit Testing
Unit testing in Kumologica involves the use of a TestCase
node to send a kumologica message (JSON payload) to subflow logic encapsulated between a Subflow-In
and Subflow-Out
nodes.
The response coming from a subflow will be encoded as a kumologica message (unlike the HTTP response from integration testing). However, if the execution of the subflow throws an error that has not been handled by the subflow, an HTTP Response containing information about the error will be returned to the TestCase
and subsequently passed to the Assertions
nodes.
The diagram below captures the outlined unit test process:
Similarly, the following diagram represents the scenario where an unhandled error is found within the subflow:
# Environment
All the environment parameters that are required to run the test can be defined in the test tab. Properties set in here will be available to the nodes within your flow under the object: env
Following is an example of two properties injected to the environment for testing:
# Assertions
Assertions is a basic element of testing. In Kumologica, an assertions is a node type: Assertion
that you can chain together in order to validate any part of the response returned by a flow or sublflow.
A test is marked as passed if all assertions are valid. The result of the assertions will be displayed on the assertions tab or in the test summary if triggered via kl test
command.
Following is an example of assertions result after a test execution:
# Further Reading
Testing Nodes: Delve into the specifics of test nodes such as
TestCase
,HTTPTestCase
,Assertion
, andTestCaseEnd
Visit the Testing reference section.CLI Test Command: For detailed information on utilizing test command through the CLI. Visit the Testing CLI secion