Verify multiple times within the same test method? #806
-
I have code like this: await Verify(uploadDetails)
.ScrubInlineGuids()
.ScrubMember("Policy");
var policy = Encoding.UTF8.GetString(
Convert.FromBase64String((string)uploadDetails.Fields["Policy"]));
await VerifyJson(policy)
.UseFileName("test")
.ScrubInlineGuids(); ... but Verify only seems to work for the first call. Is this not possible? I would have expected this to work, even without the I'm aware of #772, but even if it was possible (I'm trying to target a specific dictionary key), I think that it makes more sense for it to be written to a separate file, otherwise it looks like this property is actually an object in the first snapshot. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
try this
|
Beta Was this translation helpful? Give feedback.
-
Just because I arrived here looking for something similar -- I ended up writing an extension method to tack on an "instance" of uniqueness: public static SettingsTask UniqueForInstance(this SettingsTask verify,
string instanceName,
[CallerMemberName] string? callingMethod = null)
=> verify.UseMethodName($"{callingMethod}_{instanceName}"); Usage is then like: await Verify(uploadDetails)
.ScrubInlineGuids()
.ScrubMember("Policy");
// .UniqueForInstance("withoutPolicy"); // don't need this for the first one
//....
await Verify(policy)
.ScrubInlineGuids()
.UniqueForInstance(nameof(policy)); // makes a second file with the instance suffix |
Beta Was this translation helpful? Give feedback.
you can call Verify multiple times, but you must supply some extra uniqueness. for example using
.UseMethodName("customName")