Skip to content

Commit ca9b5b6

Browse files
committed
Use Verify instead of Shouldly
Verify automatically supports opening a diff viewer during development and producing an error when running on CI. Also, Verify is configurable through [environment variables][1] to use your preferred diff viewer. [1]: https://github.com/VerifyTests/DiffEngine/blob/main/docs/diff-tool.order.md
1 parent 74a823f commit ca9b5b6

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
using PublicApiGenerator;
22
using Serilog.Settings.Configuration;
3-
using Shouldly;
4-
using Xunit;
53

4+
[UsesVerify]
65
public class ApiApprovalTests
76
{
87
[Fact]
9-
public void PublicApi_Should_Not_Change_Unintentionally()
8+
public Task PublicApi_Should_Not_Change_Unintentionally()
109
{
1110
var assembly = typeof(ConfigurationReaderOptions).Assembly;
12-
var publicApi = assembly.GeneratePublicApi(
13-
new()
14-
{
15-
IncludeAssemblyAttributes = false,
16-
ExcludeAttributes = new[] { "System.Diagnostics.DebuggerDisplayAttribute" },
17-
});
18-
19-
publicApi.ShouldMatchApproved(options =>
20-
{
21-
// Comment this line out to view the failure as a diff. Leave it here so that CI builds don't hang when this test fails.
22-
options.NoDiff();
23-
options.WithFilenameGenerator((_, _, fileType, fileExtension) => $"{assembly.GetName().Name!}.{fileType}.{fileExtension}");
24-
});
11+
var publicApi = assembly.GeneratePublicApi(new() { IncludeAssemblyAttributes = false });
12+
return Verify(publicApi).UseFileName(assembly.GetName().Name!);
2513
}
2614
}

test/Serilog.Settings.Configuration.ApprovalTests/Serilog.Settings.Configuration.ApprovalTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
9+
<PackageReference Include="Verify.Xunit" Version="19.12.0" />
910
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" PrivateAssets="all" />
1011
<PackageReference Include="xunit" Version="2.4.2" />
11-
<PackageReference Include="Shouldly" Version="4.1.0" />
1212
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
1313
</ItemGroup>
1414

0 commit comments

Comments
 (0)