foundry
foundry copied to clipboard
Reverting and stopping execution using assertEq
Hey, not sure if I should upload this issue here or in foundry repo, but with the implementation of this commit: https://github.com/foundry-rs/forge-std/commit/14325182bf0aae5b2b858f5f0351ffe35c643248 the behavior of assertEq changed (and I assume the others as well). It is now reverting and stopping execution instead of throwing a simple log and test failure.
I would believe this behavior change is not intended and we'd want to still stick with the original one (referred from example here: https://github.com/foundry-rs/foundry/blob/651cec1665d785a2671d666a7bdfe55dd3eeebfb/crates/evm/evm/src/executors/mod.rs#L426).
forge --version
forge 0.2.0 (e01038f 2024-04-25T00:29:53.251953000Z)
This was intended behavior. Do you have a use case for continuing execution after failure? If so, perhaps it's feasible to add a flag to toggle the behavior used
This was intended behavior. Do you have a use case for continuing execution after failure? If so, perhaps it's feasible to add a flag to toggle the behavior used
Nothing too specific but in general when running the tests for first time is nice to catch all the possible errors at once for correcting them (whatever they are contract or test ones) than having to fix it, run again, fix, run again...
Thank you for the feedback. I have also thought this a few times, e.g. when making a large change and expecting a lot of assertions to fail. cc @klkvr for thoughts
Agree with @sunbreak1211 here I think its valuable to be able to see all the assertion failed expected and actual values when a test fails. Makes for much faster debugging.
One example is changing a value in one place that causes a bunch of assertions to fail, I can just run the tests to update the values and do it in one shot vs. having to run the tests for as many failing assertions there are (could be a lot).
This has been resolved in https://github.com/foundry-rs/foundry/issues/8049 + https://github.com/foundry-rs/foundry/pull/8263
It is now possible to configure this behavior by setting the configuration in foundry.toml
By default:
# Whether `failed()` should be invoked to check if the test have failed.
legacy_assertions = false
# Whether failed assertions should revert.
assertions_revert = true
This has been resolved in #8049 + #8263
It is now possible to configure this behavior by setting the configuration in
foundry.tomlBy default:
# Whether `failed()` should be invoked to check if the test have failed. legacy_assertions = false # Whether failed assertions should revert. assertions_revert = true
Thank you