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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TestBucket.Traits.Xunit" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TestBucket.Traits.Xunit" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="TestBucket.Traits.Xunit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TestBucket.Traits.Xunit --version 1.0.5
                    
#r "nuget: TestBucket.Traits.Xunit, 1.0.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=TestBucket.Traits.Xunit&version=1.0.5
                    
Install TestBucket.Traits.Xunit as a Cake Addin
#tool nuget:?package=TestBucket.Traits.Xunit&version=1.0.5
                    
Install TestBucket.Traits.Xunit as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
1.0.5 219 6/13/2025
1.0.4 242 6/13/2025
1.0.3 276 6/11/2025
1.0.2 268 6/11/2025
1.0.1 153 4/24/2025
1.0.0 232 4/3/2025