-
I created a small testing contract (from @PatrickAlphaC's foundry intro video) and was able to successfully run tests. However, as I added tests, I found that the order the For example, in an effort to only test one assertion per function, I added a second test that checked that the address's balance of staked ERC20 token was in line with the amount that was deposited in the first test. However, this test always ran first, before the deposit had occurred. As a result, it always fails. Is there documentation about how |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Tests are executed in parallel, so you can't depend on order of test execution. (Note that individual runs of a fuzz test are run serially, however). You can use different contracts with different Ideally your tests should be isolated and not dependent on each other, and having more than one |
Beta Was this translation helpful? Give feedback.
Tests are executed in parallel, so you can't depend on order of test execution. (Note that individual runs of a fuzz test are run serially, however). You can use different contracts with different
setUp()
methods, or you can calltest1()
from withintest2()
to acquire its state, but this will result in test1 running twice.Ideally your tests should be isolated and not dependent on each other, and having more than one
assertEq
per test is common 🙂