Skip to content

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

Description

@nedtwigg

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjvm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions