foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.18k stars 1.7k forks source link

Snapshot tests #797

Open onbjerg opened 2 years ago

onbjerg commented 2 years ago

This issue is to discuss the possibility of using snapshot testing in various capacities.

Places I think it will definitely make sense to use snapshot tests:

Additionally, it might make sense to use snapshot tests for a larger Solidity test suite. Currently we have testdata directories in multiple crates, some with duplicate tests, and some that are entirely unused. Some crates refer directly to evm-adapters/testdata instead.

I propose we create a top-level directory with various tests inside. Each test would be in its own folder and could either be a full project (for CLI integration tests) or single files (for behavioural tests).

There are also some obvious drawbacks to snapshot tests however that we must keep in mind:

What are your thoughts?

Snapshot test library for Rust: https://crates.io/crates/insta

onbjerg commented 2 years ago

See also a thought I had for the behavioural tests for the test runners that might be better: https://github.com/onbjerg/foundry-test (the repo is a test suite I'm building up while migrating to REVM)

gakonst commented 2 years ago

Supportive of the idea, no strong opinions on the form factor