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 #69

Open
killercup opened this issue Dec 1, 2018 · 2 comments
Open

Snapshot tests #69

killercup opened this issue Dec 1, 2018 · 2 comments
Labels
enhancement Improve the expected

Comments

@killercup
Copy link

Did we ever talk about snapshot tests? I don't recall, and I didn't find an issue in this or the assert_{cmd,cli} repos.

The idea is this: Instead of manually writing predicate::path::eq_file(Path::new("some.file")).utf8().unwrap();, you'd have a predicate::eq_snapshot!() macro that expands to a uniq filename predicate with the ability to create that file with the content it gets on the first test run or when using RECORD_SNAPSHOTS=1 or something similar.

@epage epage added the enhancement Improve the expected label Dec 1, 2018
@epage
Copy link
Contributor

epage commented Dec 1, 2018

Good idea. While "golden state" tests are brittle, they can be useful and making it easier to update them would be a big help.

We'll also want to look into this for #33. The main impact of #33 on this issue is ensuring we have good names for both of them.

I'm assuming the snapshots would be kept under revision control.

Options for where to store

  • Fixed location under tests/fixtures.
  • Require the path be specified
  • Use a builder for this (e.g. predicate::eq_snapshot!().from("tests/fixtures")) with a default location

Next, what is the snapshot's filename

eq_snapshot would probably want a .utf8() like eq_file so we know when can provide more useful failure messages.

Any other API considerations?

@epage
Copy link
Contributor

epage commented Jan 21, 2019

See insta for ideas we could pillage
https://crates.io/crates/insta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants