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

Snapshot tests #797

Open
onbjerg opened this issue Feb 23, 2022 · 2 comments
Open

Snapshot tests #797

onbjerg opened this issue Feb 23, 2022 · 2 comments
Labels
A-testing Area: testing

Comments

@onbjerg
Copy link
Member

onbjerg commented Feb 23, 2022

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:

  • forge fmt tests since it takes some text and transforms it. Updating the tests for a full-fledged formatting run can end up being a pain.
  • forge flatten tests. Same reasoning as above.

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:

  • We need to be strict with accepting changes to snapshots
  • We need to be careful not to overuse snapshot tests, i.e. we should only use snapshot tests in cases where we want to test large outputs against complex inputs. If we're testing against a very specific behaviour, e.g. that a field or two have a specific value, then we should use unit tests instead.

What are your thoughts?

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

@onbjerg onbjerg added the T-meta Type: meta label Feb 23, 2022
@onbjerg
Copy link
Member Author

onbjerg commented Feb 23, 2022

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)

@onbjerg onbjerg added the T-question Type: question label Feb 23, 2022
@gakonst
Copy link
Member

gakonst commented Feb 28, 2022

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

@zerosnacks zerosnacks added A-testing Area: testing and removed T-question Type: question T-meta Type: meta labels Jun 27, 2024
@zerosnacks zerosnacks modified the milestone: v1.0.0 Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing Area: testing
Projects
No open projects
Status: Todo
Development

No branches or pull requests

3 participants