-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
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
- such as calling
- 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
selfie/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/WriteTracker.kt
Lines 70 to 94 in edb5f65
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
hotToFixis completely buried. It should come first! - We should also advertise the
allow_multiple_equivalent_writes_to_one_locationproperty