Run Foundry Tests
evm_run_testsRun Foundry forge tests and get structured results with per-test status, fuzz counterexamples, and gas metrics to verify smart contract behavior after changes.
Instructions
Run forge test and return structured per-suite, per-test results — including fuzz runs and the exact counterexample calldata for failing fuzz/invariant tests.
Use this to verify behavior equivalence after a rewrite, run invariant suites, or drive a Generate-Repair-Execute proof-of-concept loop.
Args:
projectPath (string): Absolute path to the Foundry project root
matchTest (string, optional): Only run test functions matching this regex (forge --match-test)
matchPath (string, optional): Only run test files matching this glob (forge --match-path)
Returns: JSON object: { "allPassed": boolean, "totalPassed": number, "totalFailed": number, "totalSkipped": number, "suites": [ { "name": string, // e.g. "test/Vault.t.sol:VaultTest" "passed": number, "failed": number, "skipped": number, "tests": [ { "name": string, // e.g. "testFuzz_withdraw(uint256)" "status": string, // "pass" | "fail" | "skip" "reason": string, // Failure reason (on fail) "counterexample": string, // Fuzz counterexample calldata + args (on fuzz fail) "gas": number, // Gas for unit tests "fuzzRuns": number, // Runs for fuzz/invariant tests "medianGas": number // Median gas for fuzz tests } ] } ] }
Examples:
"Do my invariant tests still hold?" → matchTest = "invariant"
"Verify the refactor didn't break Vault" → matchPath = "test/Vault.t.sol"
Error Handling:
Returns isError=true if forge is not installed, the path is invalid, or compilation fails (use evm_compile_and_diagnose for compiler errors)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| matchPath | No | Only run test files matching this glob | |
| matchTest | No | Only run test functions matching this regex | |
| projectPath | Yes | Absolute path to the Foundry project root |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| suites | Yes | ||
| allPassed | Yes | ||
| totalFailed | Yes | ||
| totalPassed | Yes | ||
| totalSkipped | Yes |