Skip to content

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented Jan 17, 2025

Write Traits into Properties section of TRX.

[TestProperty("some property", "some value")] // MSTest

[Property("some property", "some value")] // NUnit

[Trait("some property", "some value")] //Xunit

TRX:

 <UnitTest name="TestMethod1_1" storage="s:\t\mstest1.dll" id="0b592ca2-9fc4-1d7f-bdcd-3e8f8a552f24">
      <Properties>
        <Property Key="custom-owner" Value="Jakub" />
        <Property Key="my-service" Value="my service" />
        <Property Key="some prop" Value="some value" />
      </Properties>
      <Execution id="4bdf49fd-c016-4258-b63b-c5f8e65352ab" />
      <TestMethod codeBase="S:\t\MSTest1.dll" adapterTypeName="executor://mstestadapter/v2"
         className="MSTest1.UnitTest1" name="TestMethod1_1" />
    </UnitTest>

Where property attributes can be placed is controlled by the testing framework.

  • mstest, only on methods
  • xunit on classes and methods
  • nunit on assemblies, classes, and methods

Each property on assembly and class is propagated to all child tests.

@nohwnd nohwnd marked this pull request as draft January 17, 2025 14:34
@nohwnd nohwnd marked this pull request as ready for review January 17, 2025 14:39
@nohwnd nohwnd enabled auto-merge (squash) January 17, 2025 14:39
@nohwnd nohwnd disabled auto-merge January 20, 2025 11:28
@nohwnd nohwnd merged commit fa4e09f into microsoft:main Jan 20, 2025
7 checks passed
nohwnd added a commit that referenced this pull request May 29, 2025
nohwnd added a commit that referenced this pull request May 29, 2025
nohwnd added a commit that referenced this pull request Jun 2, 2025
This was referenced Jul 21, 2025
This was referenced Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant