refer to:
https://book.getfoundry.sh/
创建项目:
forge init test_foundry
内容如下:
... ./lib/forge-std/test/mocks ./lib/forge-std/test/mocks/MockERC20.t.sol ./lib/forge-std/test/mocks/MockERC721.t.sol ./lib/forge-std/test/StdAssertions.t.sol ./lib/forge-std/test/StdChains.t.sol ./lib/forge-std/test/StdCheats.t.sol ./lib/forge-std/test/StdError.t.sol ./lib/forge-std/test/StdJson.t.sol ./lib/forge-std/test/StdMath.t.sol ./lib/forge-std/test/StdStorage.t.sol ./lib/forge-std/test/StdStyle.t.sol ./lib/forge-std/test/StdToml.t.sol ./lib/forge-std/test/StdUtils.t.sol ./lib/forge-std/test/Vm.t.sol ./README.md ./script ./script/Counter.s.sol ./src ./src/Counter.sol ./test ./test/Counter.t.sol
forge build
[⠢] Compiling... [⠰] Compiling 27 files with 0.8.23 [⠑] Solc 0.8.23 finished in 1.08s Compiler run successful!
forge test
[⠢] Compiling... No files changed, compilation skipped Ran 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 30688, ~: 31310) [PASS] test_Increment() (gas: 31325) Suite result: ok. 2 passed; 0 failed; 0 skipped; finished in 10.09ms (9.52ms CPU time) Ran 1 test suite in 22.32ms (10.09ms CPU time): 2 tests passed, 0 failed, 0 skipped (2 total tests)