Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cheatcode to skip tests on condition, with clear output #3845

Closed
alcueca opened this issue Dec 6, 2022 · 2 comments
Closed

Add a cheatcode to skip tests on condition, with clear output #3845

alcueca opened this issue Dec 6, 2022 · 2 comments
Labels
T-feature Type: feature

Comments

@alcueca
Copy link

alcueca commented Dec 6, 2022

Component

Forge

Describe the feature you would like

When coding a test harness for live contracts, it is not possible to know in advance the state the the smart contracts will be in. Therefore, some tests will make sense, and others will not.

For example, we might have a set of tests that make sense on a given uninitialized contract, but once the contract is initialized it would make more sense to skip those tests and move on to the next ones in the same file.

There is an easy workaround in making the test return if a certain condition is met, with a console log to say that the test was skipped. However, in the output it still comes as PASS and that might lead to confusion.

I would very much prefer if the test would show as SKIP, and maybe even in the summary at the end ("67 passed, 32 skipped, 0 failed", for example).

Additional context

In this test file, this test only makes sense in the contract is in an EJECTED state after the setup function.

@alcueca alcueca added the T-feature Type: feature label Dec 6, 2022
@mds1
Copy link
Collaborator

mds1 commented Dec 7, 2022

Agreed this would be useful, I think vm.skip(bool) or vm.skipTest(bool) is the best UX here. Also a duplicate of #1123 if you want to move the discussion there

@alcueca
Copy link
Author

alcueca commented Dec 7, 2022

Moving to #1123, thanks @mds1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
None yet
Development

No branches or pull requests

2 participants