Created
February 12, 2023 13:43
-
-
Save PaulRBerg/9d9b2d6f88c265336b72357024af3d60 to your computer and use it in GitHub Desktop.
Simple Solidity test tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity >=0.8.18; | |
import { PRBTest } from "@prb/test/PRBTest.sol"; | |
contract Foo is PRBTest { | |
function test_RevertWhen_CallerNotOwner() external { | |
vm.expectRevert(); | |
// ... | |
} | |
modifier callerOwner() { | |
_; | |
} | |
function test_RevertWhen_DepositZero() external callerOwner { | |
vm.expectRevert(); | |
// ... | |
} | |
modifier depositNotZero() { | |
_; | |
} | |
function test_MyFunc() external callerOwner depositNotZero { | |
// ... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo.t.sol | |
├── when the caller is not the owner | |
│ └── it should revert | |
└── when the caller is the owner | |
├── when the deposit is zero | |
│ └── it should revert | |
└── when the deposit is not zero | |
└── it should work |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment