Mule Testing
Create MUnit evidence for the current project's actual behavior. Treat coverage as a navigation aid,
not the definition of correctness, and keep reusable guidance free of project identity and private
data.
Establish the authority and boundary
- Read repository instructions,
pom.xml, mule-artifact.json, the production flow under test,
its callers or source, effective error handling, relevant contracts, and existing MUnit suites.
- Read the shared
mule-lint standards protocol, then load
MSTD-TEST-001 and mule-lint://docs/testing when the MCP resource is available. If it is not,
use Behavior model as the bundled minimum.
- Use the canonical Classes A–E from
mule-development for value, embedded
expression, contract, failure, and state behavior. Apply relevant security, capacity, delivery,
privacy, and validation gates.
- Keep production changes outside this skill. If a correct test exposes a product defect, report
it and route the source fix through
mule-development; do not weaken the test to preserve the
defect.
Never copy application names, endpoints, payloads, identifiers, schedules, volumes, incident data,
topology, or tuning values from another project. Use only current-project evidence in current-project
tests, and use neutral synthetic values in reusable examples.
Inventory before editing
Run the read-only inventory from this skill directory:
python3 <skill-root>/scripts/inventory_munit.py <project-root> --pretty
<skill-root> is ${CLAUDE_PLUGIN_ROOT}/skills/mule-testing for the Claude plugin and
.agents/skills/mule-testing when vendored into a project. The inventory reports structure and names, not
fixture contents or selector values. A valid Mule project with no tests is a successful inventory
with an evidence gap; a non-Mule target or invalid argument exits with status 2.
Reconcile the inventory with direct source inspection. It uses name mentions only as a heuristic for
flow-to-test mapping and never proves behavioral coverage.
Build a behavior ledger
Before writing tests, record each material case using the template in references/behavior-model.md:
- trigger or caller and input-event shape;
- dependency and state preconditions;
- expected payload, attributes, variables, error, and source/caller outcome;
- required interactions and interactions that must not occur;
- retry, redelivery, acknowledgement, idempotency, and state effects where applicable.
Cover cases by risk and behavior, not by one-test-per-flow or a universal percentage. Consider
success, meaningful alternatives, empty or invalid input, dependency failure, retry exhaustion,
terminal disposition, replay, and recovery only when the implementation can exercise them.
Author or repair the tests
- Reuse the project's established suite layout, naming, fixture style, namespace versions, and
MUnit plugin configuration.
- Construct the event the real caller or source supplies: payload value and media type, attributes,
variables, correlation context, and any required source metadata.
- Mock stable boundaries such as HTTP, database, queue, file, or external flow dependencies when
isolation is intended. Do not mock the transformation, routing, state decision, or error behavior
being tested.
- Make selectors discriminate the intended call using stable processor identity and inputs. Avoid
a broad mock that can hide an unexpected branch.
- Assert observable behavior: output values and types, variables or attributes, error type and
disposition, state changes, and source/caller outcomes. Verify important boundary calls and use
negative verification when an interaction must not occur.
- Use spies only when before/after observation is the least coupled way to establish a behavior;
do not substitute internal-step assertions for an observable outcome.
- Keep fixtures synthetic, minimal, schema-faithful, and free of secrets, raw production payloads,
tenant details, private hosts, personal data, and identifiers copied from elsewhere.
When repairing a failure, classify it before editing: product regression, stale expectation,
unfaithful event or fixture, mock mismatch, environment/build failure, or flaky nondeterminism. Change
only the layer supported by evidence. Never delete an assertion, broaden a mock, ignore a test, or
lower a gate merely to make the suite pass.
Validate
Run the narrowest deterministic test first, then the repository-required broader gate:
- Prefer
mule-build run_tests with cwd and an exact suite, test, or tag selection.
- Otherwise use the project's established Maven or wrapper command and its pinned profile.
- Inspect the MUnit report and first actionable failure, not only the process exit status.
- Run the affected suite, then the complete required test/package gate for release scope.
- Re-run the inventory and inspect the final diff for ignored tests, over-broad selectors,
production-source edits, generated reports, fixture leakage, and unrelated changes.
Do not use -DskipTests or equivalent to validate a test change. Coverage and Test Recorder can
identify unexercised paths, but no fixed percentage proves the behavior ledger is complete.
Report
Return:
- behavior cases added, repaired, or still missing;
- suites, tests, fixtures, and test-only configuration changed;
- focused and full commands or tools run, with results and report paths;
- failure classification when a test was repaired;
- skipped checks, environment limitations, production defects, and remaining evidence gaps.
1---2name: mule-testing3description: Create, repair, and refactor behavior-focused MUnit tests for MuleSoft Mule 4 applications, including event setup, fixtures, mocks, spies, assertions, error expectations, and test-only build configuration. Use when adding missing MUnit coverage, diagnosing or fixing a failing MUnit test, preserving behavior during a Mule change, or improving test fidelity. Route production Mule source changes to mule-development and execution-only, packaging, or release work to mule-build.4---56# Mule Testing78Create MUnit evidence for the current project's actual behavior. Treat coverage as a navigation aid,9not the definition of correctness, and keep reusable guidance free of project identity and private10data.1112## Establish the authority and boundary13141. Read repository instructions, `pom.xml`, `mule-artifact.json`, the production flow under test,15 its callers or source, effective error handling, relevant contracts, and existing MUnit suites.162. Read the shared17 [mule-lint standards protocol](../mule-development/references/mule-lint-standards.md), then load18 `MSTD-TEST-001` and `mule-lint://docs/testing` when the MCP resource is available. If it is not,19 use [Behavior model](references/behavior-model.md) as the bundled minimum.203. Use the canonical Classes A–E from21 [mule-development](../mule-development/references/invariant-classes.md) for value, embedded22 expression, contract, failure, and state behavior. Apply relevant security, capacity, delivery,23 privacy, and validation gates.244. Keep production changes outside this skill. If a correct test exposes a product defect, report25 it and route the source fix through `mule-development`; do not weaken the test to preserve the26 defect.2728Never copy application names, endpoints, payloads, identifiers, schedules, volumes, incident data,29topology, or tuning values from another project. Use only current-project evidence in current-project30tests, and use neutral synthetic values in reusable examples.3132## Inventory before editing3334Run the read-only inventory from this skill directory:3536```bash37python3 <skill-root>/scripts/inventory_munit.py <project-root> --pretty38```3940`<skill-root>` is `${CLAUDE_PLUGIN_ROOT}/skills/mule-testing` for the Claude plugin and41`.agents/skills/mule-testing` when vendored into a project. The inventory reports structure and names, not42fixture contents or selector values. A valid Mule project with no tests is a successful inventory43with an evidence gap; a non-Mule target or invalid argument exits with status 2.4445Reconcile the inventory with direct source inspection. It uses name mentions only as a heuristic for46flow-to-test mapping and never proves behavioral coverage.4748## Build a behavior ledger4950Before writing tests, record each material case using the template in `references/behavior-model.md`:5152- trigger or caller and input-event shape;53- dependency and state preconditions;54- expected payload, attributes, variables, error, and source/caller outcome;55- required interactions and interactions that must not occur;56- retry, redelivery, acknowledgement, idempotency, and state effects where applicable.5758Cover cases by risk and behavior, not by one-test-per-flow or a universal percentage. Consider59success, meaningful alternatives, empty or invalid input, dependency failure, retry exhaustion,60terminal disposition, replay, and recovery only when the implementation can exercise them.6162## Author or repair the tests63641. Reuse the project's established suite layout, naming, fixture style, namespace versions, and65 MUnit plugin configuration.662. Construct the event the real caller or source supplies: payload value and media type, attributes,67 variables, correlation context, and any required source metadata.683. Mock stable boundaries such as HTTP, database, queue, file, or external flow dependencies when69 isolation is intended. Do not mock the transformation, routing, state decision, or error behavior70 being tested.714. Make selectors discriminate the intended call using stable processor identity and inputs. Avoid72 a broad mock that can hide an unexpected branch.735. Assert observable behavior: output values and types, variables or attributes, error type and74 disposition, state changes, and source/caller outcomes. Verify important boundary calls and use75 negative verification when an interaction must not occur.766. Use spies only when before/after observation is the least coupled way to establish a behavior;77 do not substitute internal-step assertions for an observable outcome.787. Keep fixtures synthetic, minimal, schema-faithful, and free of secrets, raw production payloads,79 tenant details, private hosts, personal data, and identifiers copied from elsewhere.8081When repairing a failure, classify it before editing: product regression, stale expectation,82unfaithful event or fixture, mock mismatch, environment/build failure, or flaky nondeterminism. Change83only the layer supported by evidence. Never delete an assertion, broaden a mock, ignore a test, or84lower a gate merely to make the suite pass.8586## Validate8788Run the narrowest deterministic test first, then the repository-required broader gate:89901. Prefer `mule-build` `run_tests` with `cwd` and an exact suite, test, or tag selection.912. Otherwise use the project's established Maven or wrapper command and its pinned profile.923. Inspect the MUnit report and first actionable failure, not only the process exit status.934. Run the affected suite, then the complete required test/package gate for release scope.945. Re-run the inventory and inspect the final diff for ignored tests, over-broad selectors,95 production-source edits, generated reports, fixture leakage, and unrelated changes.9697Do not use `-DskipTests` or equivalent to validate a test change. Coverage and Test Recorder can98identify unexercised paths, but no fixed percentage proves the behavior ledger is complete.99100## Report101102Return:1031041. behavior cases added, repaired, or still missing;1052. suites, tests, fixtures, and test-only configuration changed;1063. focused and full commands or tools run, with results and report paths;1074. failure classification when a test was repaired;1085. skipped checks, environment limitations, production defects, and remaining evidence gaps.