foundry-test-functions

September 16, 2025 ยท View on GitHub

Category Badge Default Severity Badge warn

Description

Enforce naming convention on functions for Foundry test cases (DEPRECATED, use foundry-test-functions-naming)

Options

This rule accepts an array of options:

IndexDescriptionDefault Value
0Rule severity. Must be one of "error", "warn", "off".warn
1Array of required Foundry test hook function names.setUp

Example Config

{
  "rules": {
    "foundry-test-functions": [
      "warn",
      [
        "setUp"
      ]
    ]
  }
}

Notes

  • This rule can be configured to skip certain function names in the SKIP array. In Example Config. setUp function will be skipped
  • Supported Regex: test(Fork)?(Fuzz)?(Fail)?_(Revert(If_|When_){1})?\w{1,}
  • This rule should be executed in a separate folder with a separate .solhint.json => solhint --config .solhint.json testFolder/**/*.sol
  • This rule applies only to external and public functions
  • This rule skips the setUp() function by default

Examples

๐Ÿ‘ Examples of correct code for this rule

Foundry test case with correct Function declaration

function test_NumberIs42() public {}

Foundry test case with correct Function declaration

function testFail_Subtract43() public {}

Foundry test case with correct Function declaration

function testFuzz_FuzzyTest() public {}

๐Ÿ‘Ž Examples of incorrect code for this rule

Foundry test case with incorrect Function declaration

function numberIs42() public {}

Version

This rule was introduced in Solhint 3.6.1

Resources