TestBucket.Traits.Xunit
1.0.5
dotnet add package TestBucket.Traits.Xunit --version 1.0.5
NuGet\Install-Package TestBucket.Traits.Xunit -Version 1.0.5
<PackageReference Include="TestBucket.Traits.Xunit" Version="1.0.5" />
<PackageVersion Include="TestBucket.Traits.Xunit" Version="1.0.5" />
<PackageReference Include="TestBucket.Traits.Xunit" />
paket add TestBucket.Traits.Xunit --version 1.0.5
#r "nuget: TestBucket.Traits.Xunit, 1.0.5"
#addin nuget:?package=TestBucket.Traits.Xunit&version=1.0.5
#tool nuget:?package=TestBucket.Traits.Xunit&version=1.0.5
TestBucket Traits
Standardized traits and enrichment attributes for .NET unit tests.
- Standardize properties/traits/attachments in test result files by using a shared naming convention across projects
- Enrich output by collecting additional data from tests
Traits, Properties, Attachments
Depending on test framework (MSTest/xUnit/TUnit/NUnit..) and output formats (xunit, TRX, junitxml, CTRF etc) the attributes added by TestBucket traits may not match 1-to-1, but a generalized usage is as follows:
- Traits: Describes traits for the test case. Often these may show up as groupings in Visual Studio, Rider or other tools. For practical reasons these should be limited.
- Properties/Attachments: If the data is not suitable as a trait, it will be exported as a property or attachment (depending on output format).
Attributes
Attributes are named the same in both TestBucket.Traits.Xunit
and TestBucket.Traits.TUnit
packages to the extent possible.
xUnit
using TestBucket.Traits.Xunit;
namespace MyTests
{
[UnitTest]
[EnrichedTest]
public class MyTestClass
{
[Fact]
public void MyTestMethod()
{
}
}
}
TUnit
using TestBucket.Traits.TUnit;
namespace MyTests
{
[UnitTest]
public class MyTestClass
{
[Test]
public void MyTestMethod()
{
}
}
}
Test Category
The following attributes create a TestCategory trait:
- UnitTest
- ApiTest
- IntegrationTest
- EndToEndTest
Junit XML output from xunit runner
<testcase name="A">
<properties>
<property name="trait:TestCategory" value="Unit" />
</properties>
</testcase>
The xunit runner adds a trait prefix as traits are not supported in standard junitxml files
Xunit XML
<test name="A">
<traits>
<trait name="TestCategory" value="Unit" />
</traits>
</test>
Enriched Tests in xUnit
The EnrichedTestAttribute
adds attachments (xunit) which are key-value pairs similar to traits (but they won't show up in Visual Studio).
This enables attachment traits, such as:
- TestDescription
- TestId
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- TestBucket.Traits.Core (>= 1.0.5)
- xunit.v3.extensibility.core (>= 2.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TestBucket.Traits.Xunit:
Package | Downloads |
---|---|
TestBucket.AI.Xunit
MCP (Model Context Protocol) test framework for writing xunit tests that target MCP servers or AIFunction/tool calling IChatClient |
GitHub repositories
This package is not used by any popular GitHub repositories.