Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/exception-message-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Then zero or more categorized sections, each listing file pairs:
* **InlineNew** - an [inline snapshot](inline-snapshots.md) with no expected value yet.
* **InlineNotEqual** - an inline snapshot whose expected value differs from the result.

File paths in these sections are relative to the reported directory, and keep any subdirectory. `UseUniqueDirectory` and `VerifyDirectory` place snapshots in a subdirectory, so combining the reported directory with the listed path is what rebuilds the full path.

Inline entries use a different shape: a `Source:` line with the absolute source file path and 1 based line number (`path:line`), followed by optional absolute staged file paths:

```
Expand Down Expand Up @@ -242,7 +244,7 @@ static Result ParseExceptionMessage(string exceptionMessage)
return result;
}
```
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs#L291-L311' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionParsing' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs#L304-L324' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionParsing' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The `Result` contains:
Expand Down
2 changes: 2 additions & 0 deletions docs/mdsource/exception-message-format.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Then zero or more categorized sections, each listing file pairs:
* **InlineNew** - an [inline snapshot](inline-snapshots.md) with no expected value yet.
* **InlineNotEqual** - an inline snapshot whose expected value differs from the result.

File paths in these sections are relative to the reported directory, and keep any subdirectory. `UseUniqueDirectory` and `VerifyDirectory` place snapshots in a subdirectory, so combining the reported directory with the listed path is what rebuilds the full path.

Inline entries use a different shape: a `Source:` line with the absolute source file path and 1 based line number (`path:line`), followed by optional absolute staged file paths:

```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
message:
Directory: {ProjectDirectory}
Delete:
- TheType.TheMethod\old.verified.txt
,
result: {
Delete: [
{ProjectDirectory}TheType.TheMethod\old.verified.txt
]
}
}
13 changes: 13 additions & 0 deletions src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,19 @@ public Task SingleDelete()
return ParseVerify([], [], delete, []);
}

// UseUniqueDirectory and VerifyDirectory put the verified files in a subdirectory
// of the reported directory, so the parse has to give the subdirectory back
[Fact]
public Task DeleteInSubDirectory()
{
var delete = new List<string>
{
Path.Combine(projectDirectory, "TheType.TheMethod", "old.verified.txt")
};

return ParseVerify([], [], delete, []);
}

[Fact]
public Task ParseInlineNew()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Directory: {ProjectDirectory}
Delete:
- TheType.TheMethod\old.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public Task SingleDelete() =>
delete: [fakeReceivedTextFile],
equal: []);

// UseUniqueDirectory and VerifyDirectory put the verified files in a subdirectory
// of the reported directory, which a file name would drop
[Fact]
public Task DeleteInSubDirectory() =>
BuildVerify(
@new: [],
notEquals: [],
delete: [Path.Combine(projectDirectory, "TheType.TheMethod", "old.verified.txt")],
equal: []);

[Fact]
public Task SingleEqual() =>
BuildVerify(
Expand Down
5 changes: 4 additions & 1 deletion src/Verify/Verifier/VerifyExceptionMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ public static string Build(
builder.AppendLineN("Delete:");
foreach (var file in delete)
{
builder.AppendLineN($" - {Path.GetFileName(file)}");
// directory relative, like the other sections, so the parser can
// rebuild the path. UseUniqueDirectory and VerifyDirectory put the
// verified files in a subdirectory, which a file name would drop.
builder.AppendLineN($" - {IoHelpers.GetRelativePath(directory, file)}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ All six resolved 2026-08-16 (five fixed here; the inline item resolved as by-des
- [ ] **MSTest overloaded test methods resolve to the wrong `MethodInfo`.**
`Verify.MSTest/TestExecutionContext.cs:24-30` — `FindMethod` returns the first name match, ignoring parameters. With two `[DataRow]` overloads of one name, the parameter-count guard in `Verifier.BuildVerifier` mismatches for one of them → `SetParameters` silently skipped → both overloads collide on one snapshot prefix.

- [ ] **`Delete:` section drops subdirectories, breaking the parse round-trip.**
- [x] **`Delete:` section drops subdirectories, breaking the parse round-trip.**
`Verify/Verifier/VerifyExceptionMessageBuilder.cs:62` emits `Path.GetFileName(file)` while the other sections emit directory-relative paths, and `Verify.ExceptionParsing/Parser.cs:109` reconstructs with `Path.Combine(directory, name)`. For `UseUniqueDirectory()`/`VerifyDirectory` tests, a stale `{Directory}\Type.Method\old.verified.txt` parses back as the nonexistent `{Directory}\old.verified.txt`; same-named files in different subdirectories collapse.

- [ ] **`ThrowIfVerifyHasBeenRun` blames the caller instead of the API.**
Expand Down
Loading