- Testing logic in steps
- Testing a flow end to end
A helpful design pattern is to move non-orchestration logic out of your flows and into separate modules, then write unit tests for those functions. For example, say your flow file has logic embedded directly in a step:You cannot import and test that logic on its own, because it only exists inside the flow. Move it into a separate module file:Then, update the flow to import the module instead:The logic is identical in both versions of the flow; only its location changes. You can now unit test
my_flow.py
my_module.py
my_flow.py
do_logic independently of the flow, which is the point of the refactor. Separating logic from orchestration makes the code easier to maintain and test, especially when multiple flows or steps share the same logic.