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.