Workflow Unit Testing with Test Cases

The idea is:

Currently, n8n lacks a way to test workflows automatically, similar to unit tests in software development. It would be useful to define different test cases for each workflow to verify different scenarios in a structured way.

In larger organizations operating under ISO/IEC 27001 or similar information security frameworks, there is a strong requirement to demonstrate that critical processes and automated workflows work as intended and in a controlled, repeatable manner. At the moment, this is difficult to achieve with n8n without external tooling or manual evidence.

Proposed Functionality:

  1. Define Test Cases:

    • Each workflow can have one or more test cases.

    • Within a test case, you can pin output data to any node to simulate specific scenarios and mock external dependencies.

      • At the moment you can pin node output data only once per workflow, thus you can only test one scenario.
      • You can not pin several different output data to simulate different scenarios (e.g. API endpoint returns data set, API endpoint returns empty result, API endpoint returns errors, API endpoint is technically not reachable and so on…)
    • Additionally, define the expected behaviour for the workflow in this test case secenario (e.g. specific end node is called with sepcific data, specific error triggered etc.).

  2. Test Run Mode:

    • A special mode where the workflow does not run normally, but executes all test cases.

    • Outputs are automatically compared against the expected values.

    • Clear display of results (Pass/Fail per test case and node).

      • Ideally export as JUnit test result or similar, which can be parsed by most test suite tools as quasi-standard

I think it would be beneficial to add this because:

  1. Automated validation of workflows before deploying them in production.
  2. Faster detection of errors when workflows are modified or updated.
  3. Easier management of large projects with many workflows and complex data flows.
  4. Supports ISO/IEC 27001 controls, especially around:
    • change management,

    • validation of automated processes,

    • and evidence for internal and external audits.

I can’t believe this doesn’t exist on n8n yet!

1 Like

Would be super helpfull to increase stability of workflows!

Hi @mnebel

I think this feature request is pointing at a real gap.

n8n Evaluations already cover part of the need, because the :backhand_index_pointing_right: Evaluation Trigger can read a dataset from Google Sheets or a data table and send the items through the workflow one by one. It also supports limiting or filtering rows, so you can run just one test case or a small subset during development.

:backhand_index_pointing_right: Light evaluations are meant for hand-selected test cases before deployment, while metric-based evaluations are used after deployment with larger datasets and regression testing.

So I would say the current Evaluation feature already supports the “run known cases through the workflow” part very well, especially for AI workflows.

But your request is broader, because it asks for a true workflow unit-testing layer with reusable test cases, expected behavior, and pass/fail reporting. That part is still not fully covered today.

I also like the evaluation-first thinking I shared in my own topic,:backhand_index_pointing_right: Beyond Trial and Error: Applying a Modified Waterfall SDLC to the Inbox Inferno Challenge, because it matches the idea of planning tests before depending on trial-and-error fixes.

1 Like