foundry-rs / forge-std

Forge Standard Library is a collection of helpful contracts for use with forge and foundry. It leverages forge's cheatcodes to make writing tests easier and faster, while improving the UX of cheatcodes. For more in-depth usage examples checkout the tests.
Apache License 2.0
850 stars 335 forks source link

Renaming tests to follow best practices #599

Closed milosdjurica closed 1 month ago

milosdjurica commented 2 months ago

In the Foundry Book in Best Practices section there is a recommended way of naming tests, but the tests in this repo do not conform to this best practice. This is already issued in #273 .

I am open to rename those tests myself, but I just wanted to ask for some guidance before I make the changes.

Quick example : https://github.com/foundry-rs/forge-std/blob/1ce7535a517406b9aec7ea1ea27c1b41376f712c/test/StdChains.t.sol#L87

In the test/StdChains.t.sol there is a test that looks like this ->

    function test_ChainNoDefault() public {
        // We deploy a mock to properly test the revert.
        StdChainsMock stdChainsMock = new StdChainsMock();

        vm.expectRevert("StdChains getChain(string): Chain with alias \"does_not_exist\" not found.");
        stdChainsMock.exposed_getChain("does_not_exist");
    }

I am not sure how exactly to rename tests.

Just wanted to know which is a preferred way? Should I just add _RevertIf_ part where needed, or change tests names completely, where it makes sense to do so?