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

Confusing when a got-away-with-it multiple snapshot stops getting away with it #488

Open
2 tasks
nedtwigg opened this issue Nov 19, 2024 · 0 comments
Open
2 tasks
Labels
bug Something isn't working jvm

Comments

@nedtwigg
Copy link
Member

Story:

  • a user has a test where they are taking multiple snapshots that have the same name
    • such as calling toMatchDisk() twice in one test
  • the snapshots happen to be the same, so they get away with it
  • something about the code being tested changes, and now the snapshots are different, so the test fails with this error message
  • val howToFix =
    when (this) {
    is DiskWriteTracker ->
    "You can fix this with `.toMatchDisk(String sub)` and pass a unique value for sub."
    is InlineWriteTracker ->
    """
    You can fix this by doing an `if` before the assertion to separate the cases, e.g.
    if (isWindows) {
    expectSelfie(underTest).toBe("C:\\")
    } else {
    expectSelfie(underTest).toBe("bash$")
    }
    """
    is ToBeFileWriteTracker ->
    "You can fix this with `.toBeFile(String filename)` and pass a unique filename for each code path."
    }
    if (existing.snapshot != snapshot) {
    throw layout.fs.assertFailed(
    "Snapshot was set to multiple values!\n" +
    " first value: ${existing.snapshot}\n" +
    " this time: ${snapshot}\n" +
    " first call: ${existing.callStack.ideLink(layout)}\n" +
    " this call: ${call.ideLink(layout)}\n" +
    "$howToFix",
    existing.snapshot,
  • The hotToFix is completely buried. It should come first!
  • We should also advertise the allow_multiple_equivalent_writes_to_one_location property
@nedtwigg nedtwigg added bug Something isn't working jvm labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working jvm
Projects
None yet
Development

No branches or pull requests

1 participant