Search code examples
testingrustethereumsolidity

Is it possible to continue tests sequentially from prior test state with Foundry/Forge?


I'm wondering if there is a way within Forge to continue your tests sequentially, starting from the contractual end state of the last test without repasting the prior tests code as setup. Obviously I could just make one massive test, however, i would lose the gas data and such that i would receive from individual tests. Thank you in advance to anyone who can help :)


Solution

  • No, this is not possible. Each test is run in isolation, with the exception that state from setUp is preserved.

    You can make a bigger test and retain gas reporting information if you use forge test --gas-report instead of going by the gas reported by just forge test. The --gas-report flag uses transaction tracing to build a gas usage report of individual calls instead of the entire test.