For any forge test, we support filtering via matches.
➜ ~ forge t --help
Run the project's tests.
Usage: forge test [OPTIONS]
Options:
-h, --help
Print help information (use `-h` for a summary)
Test filtering:
-m, --match <PATTERN>
Only run test functions matching the specified regex pattern.
Deprecated: See --match-test
--match-test <REGEX>
Only run test functions matching the specified regex pattern
[aliases: mt]
--no-match-test <REGEX>
Only run test functions that do not match the specified regex pattern
[aliases: nmt]
--match-contract <REGEX>
Only run tests in contracts matching the specified regex pattern
[aliases: mc]
--no-match-contract <REGEX>
Only run tests in contracts that do not match the specified regex pattern
[aliases: nmc]
--match-path <GLOB>
Only run tests in source files matching the specified glob pattern
[aliases: mp]
--no-match-path <GLOB>
Only run tests in source files that do not match the specified glob pattern
[aliases: nmp]
--debug <TEST_FUNCTION>
Run a test in the debugger.
The argument passed to this flag is the name of the test function you want to run, and it works the same as --match-test.
If more than one test matches your specified criteria, you must add additional filters until only one test is found (see --match-contract and --match-path).
The matching test will be opened in the debugger regardless of the outcome of the test.
If the matching test is a fuzz test, then it will open the debugger on the first failure case. If the fuzz test does not fail, it will open the debugger on the last fuzz case.
For more fine-grained control of which fuzz case is run, see forge run.
--gas-report
Print a gas report
[env: FORGE_GAS_REPORT=]
--allow-failure
Exit with code 0 even if a test fails
[env: FORGE_ALLOW_FAILURE=]
You can use the --no-match-test <regex>
, --no-match-contract <regex>
, --no-match-path <regex>
options as shown in the help menu to skip running certain tests.
For example, if you had a bunch of tests called: testWethWorks
, testWethDoesNotWork1
and testWethDoesNotWork2
in a TestWeth
contract under test/TestWeth.t.sol
you could do the following:
forge t --no-match-test testWethDoesNot*
forge t --no-match-contract TestWeth
forge t --no-match-path ./test/TestWeth.t.sol
Hope this helps.