![]() |
VOOZH | about |
dotnet add package Nzr.Snapshot.Xunit.Extensions --version 1.1.0
NuGet\Install-Package Nzr.Snapshot.Xunit.Extensions -Version 1.1.0
<PackageReference Include="Nzr.Snapshot.Xunit.Extensions" Version="1.1.0" />
<PackageVersion Include="Nzr.Snapshot.Xunit.Extensions" Version="1.1.0" />Directory.Packages.props
<PackageReference Include="Nzr.Snapshot.Xunit.Extensions" />Project file
paket add Nzr.Snapshot.Xunit.Extensions --version 1.1.0
#r "nuget: Nzr.Snapshot.Xunit.Extensions, 1.1.0"
#:package Nzr.Snapshot.Xunit.Extensions@1.1.0
#addin nuget:?package=Nzr.Snapshot.Xunit.Extensions&version=1.1.0Install as a Cake Addin
#tool nuget:?package=Nzr.Snapshot.Xunit.Extensions&version=1.1.0Install as a Cake Tool
👁 NuGet Version
👁 NuGet Downloads
👁 GitHub last commit
👁 GitHub Actions Workflow Status
👁 GitHub License
Nzr.Snapshot.Xunit.Extensions is a simple extension library for integrating Snapshooter with xUnit. It enables custom folder organization for snapshots based on test attributes and allows for flexible snapshot management in unit tests.
SnapshotFolder attribute applied to xUnit test methods.You can install Nzr.Snapshot.Xunit.Extensions via NuGet Package Manager:
Install-Package Nzr.Snapshot.Xunit.Extensions
dotnet add package Nzr.Snapshot.Xunit.Extensions
To use this package, simply include it in your xUnit test project and apply the extension methods to match the snapshots of objects during tests.
using FluentAssertions;
using Snapshooter;
using Nzr.Snapshot.Xunit.Extensions;
public class SnapshotTests
{
[Fact]
public void Match_Without_SnapshotFolderAttribute_Should_Snapshot_Folder_In_The_Same_Folder()
{
// Arrange
var currentResult = new { City = "Nova Lima", CreatedAt = DateTimeOffset.Now };
// Assert
currentResult.Should().Match();
}
[SnapshotFolder("SnapshotExtensions")]
[Fact]
public void Match_With_SnapshotFolderAttribute_Should_Snapshot_Folder_In_Specified_Folder()
{
// Arrange
var currentResult = new { City = "Lisbon", CreatedAt = DateTimeOffset.Now };
// Assert
currentResult.Should().Match();
}
[SnapshotFolder("Shared", excludeClassName: false)]
[Fact]
public void Match_With_SnapshotFolderAttribute_Keeping_ClassName_Should_Snapshot_Folder_In_Specified_Folder()
{
// Arrange
var currentResult = new { City = "Berlin", CreatedAt = DateTimeOffset.Now };
// Assert
currentResult.Should().Match();
}
}
The SnapshotFolderAttribute is used to define custom folder paths for your snapshots.
You can optionally specify whether to exclude the class name from the snapshot file name.
Name: Specifies the folder name for snapshots.ExcludeClassName: Optional boolean to exclude the class name from the snapshot filename.[SnapshotFolder("FolderName", excludeClassName: true)]
We welcome contributions! If you'd like to contribute to this project, please fork the repository and submit a pull request. Please ensure that your code passes all tests and includes relevant documentation for new features or changes.
Nzr.Snapshot.Xunit.Extensions is licensed under the Apache License, Version 2.0, January 2004. You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
This project is provided "as-is" without any warranty or guarantee of its functionality. The author assumes no responsibility or liability for any issues, damages, or consequences arising from the use of this code, whether direct or indirect. By using this project, you agree that you are solely responsible for any risks associated with its use, and you will not hold the author accountable for any loss, injury, or legal ramifications that may occur.
Please ensure that you understand the code and test it thoroughly before using it in any production environment.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.