Loading...
Loading...
[AUTO-INVOKE] MUST be invoked BEFORE writing or modifying any test files (*.t.sol). Covers test structure, naming conventions, coverage requirements, fuzz testing, and Foundry cheatcodes. Trigger: any task involving creating, editing, or running Solidity tests.
npx skill4agent add 0xlayerghost/solidity-agent-kit solidity-testingMyToken.solMyToken.t.soltest/test_<feature>_<scenario>testFail_<feature>_<scenario>test_transfer_revertsWhenInsufficientBalancetest_stake_updatesBalanceCorrectlysetUp()--match-test--match-contract| Scenario | What to verify |
|---|---|
| Happy path | Standard input → expected output, correct state changes |
| Permission checks | Unauthorized caller → |
| Boundary conditions | Zero values, max values ( |
| Failure scenarios | Every |
| State changes | Storage updates, balance changes, event emissions ( |
| Edge cases | Empty arrays, duplicate calls, self-transfers |
| Cheatcode | Usage |
|---|---|
| Next call from |
| All calls from |
| Set |
| Set |
| Set ETH balance |
| Next call must revert with specific error |
| Verify event emission (topic checks) |
| Track storage reads/writes |
| Create labeled address for readable traces |
function testFuzz_<name>(uint256 amount) publicvm.assume()vm.assume(amount > 0 && amount < MAX_SUPPLY);forge test --fuzz-runs 10000# Run all tests
forge test
# Run specific test function
forge test --match-test test_transfer
# Run specific test contract
forge test --match-contract MyTokenTest
# Verbose output with full trace
forge test -vvvv
# Gas report
forge test --gas-report
# Fuzz with more runs
forge test --fuzz-runs 10000
# Test coverage
forge coverage
# Coverage with report
forge coverage --report lcov