Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trx logger does not include Description attribute #98

Closed
AbhitejJohn opened this issue Oct 3, 2016 · 18 comments
Closed

trx logger does not include Description attribute #98

AbhitejJohn opened this issue Oct 3, 2016 · 18 comments

Comments

@AbhitejJohn
Copy link
Contributor

Description

Test description attributes like Description, CssIteration, WorkItem, CssProjectStructure do not show up in the trx log. Only Owner and Priority are part of the log.

Steps to reproduce

  1. Create an MSTest V1 based project.
  2. Add a DescriptionAttribute on top of the test method.
  3. Run tests with trx turned on.

Expected behavior

The trx should have the description string associated with the test in the log.

Actual behavior

The description string does not show up in the log.

Environment

I'm trying this on Dev15 prev-5 and on Windows 10.

@AbhitejJohn
Copy link
Contributor Author

@codito
Copy link
Contributor

codito commented Oct 3, 2016

Description attribute is very specific to a particular test framework. Should there be a extensibility point for test frameworks contribute data into trx logger?

@Faizan2304 what do you think?

@codito
Copy link
Contributor

codito commented Oct 3, 2016

@AbhitejJohn is this a regression since Dev14 Update 3?

@AbhitejJohn
Copy link
Contributor Author

@codito : DescriptionAttribute was just an example. All these do not show up: Description, CssIteration, WorkItem, CssProjectStructure. They however do get filled in properly when run from mstest.exe though.

IMHO all traits that frameworks fill in need to be part of trx. The goal is to not hard code of-course.

This has been the behaviour in TP V1 for a long time though. We only put in Priority and Owner but the drawback for this is with reporting this in VSTS or any place else.

@codito
Copy link
Contributor

codito commented Oct 5, 2016

@AbhitejJohn makes sense. A sample trx with Priority looks like following:

    <UnitTest name="TestWithPriority" storage="g:\tmp\unittestproject1.dll" priority="0" id="f2daad78-aff7-a545-f0ba-d1d27d5b0789">
      <Execution id="40c5e9e7-9349-4a0e-a885-393691579e2a" />
      <TestMethod codeBase="G:\tmp\UnitTestProject1.dll" executorUriOfAdapter="executor://mstestadapter/v2" className="SampleUnitTestProject.UnitTest1" name="TestWithPriority" />
    </UnitTest>

Would an output like below make sense? Note the Traits section.

    <UnitTest name="TestWithPriority" storage="g:\tmp\unittestproject1.dll" priority="0" id="f2daad78-aff7-a545-f0ba-d1d27d5b0789">
      <Execution id="40c5e9e7-9349-4a0e-a885-393691579e2a" />
      <TestMethod codeBase="G:\tmp\UnitTestProject1.dll" executorUriOfAdapter="executor://mstestadapter/v2" className="SampleUnitTestProject.UnitTest1" name="TestWithPriority" />
       <Traits>
            <Trait Name="Description" Value="Sample description" />
            <Trait Name="ComplexData" Value="{ jsonArray: [ 1, 2, 3] }" />
       </Traits>
    </UnitTest>

@pvlakshm @sbaid what do you think?

@AbhitejJohn
Copy link
Contributor Author

We would want to figure out a schema that fits in with TRI extensibility as well so that these results show up on VSTS.

@codito codito added question and removed exp: cli labels Oct 6, 2016
@pvlakshm
Copy link
Contributor

Triage: will talk to customers to understand scenario and importance.

@dotMorten
Copy link
Contributor

It's already in the TRX schema:

    <xs:element name="Properties" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Property" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Key" />
                  <xs:element name="Value" />
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="WorkItemIDs" type="WorkItemIDsType" minOccurs="0">
        <xs:annotation>
          <xs:documentation>References to workitems (bugs, issues) related to this test on the team server.</xs:documentation>
        </xs:annotation>
      </xs:element>

Essentially any use of [TestProperty] should go in here. I was able to use it in my own TRX logger, and it passes schema validation

@smadala
Copy link
Contributor

smadala commented Aug 6, 2018

@dotMorten Thanks for info. Do you like to patch vstest TRX logger with your TRX logger?

@smadala smadala self-assigned this Aug 6, 2018
@pvlakshm
Copy link
Contributor

pvlakshm commented Aug 6, 2018

This ought to be validated across adapters to ensure there are no surprises.

@dotMorten
Copy link
Contributor

@smadala My logger is completely different from yours. I would have preferred being able to reuse the TRX logger you have (a .NET Standard version that can serialize an IEnumerable<TestResult> would be appreciated !), but found it overly complex to deal with and would need a lot of forking.

I could try and take a stab at it, but yours is so much more complex :-)

@DmitryNaumovA1qa
Copy link

Is there a fix for the issue?
If so which version of .net core should I use to be able to include description attribute?

@dotMorten
Copy link
Contributor

@DmitryNaumovA1qa no 😒

@dotMorten
Copy link
Contributor

dotMorten commented Oct 18, 2018

Just submitted a PR that ensures CSS*, Description, WorkItemIDs and TestProperties gets written to the TRX

@OsirisTerje
Copy link

The Trx logger does not write out categories from NUnit, because the category type name is hardcoded to "MSTestDiscoverer.TestCategory", whereas the NUnit name is "NUnit.TestCategory". The idea back in 2012 was that categories should be Traits that where not hardcoded to anything in particular. Can we a) get this fixed so that any trait show up in the trx file? or b) Add in the NUnit category type name ?

See issue nunit/nunit3-vs-adapter#506

We [NUnit] accepted a PR to include the MSTest name as a temporary workaround until this was fixed, but it turns out this results in duplicate categories in the Test Explorer. nunit/nunit3-vs-adapter#559

@dotMorten
Copy link
Contributor

@OsirisTerje I'm not sure about the relevance wrt writing a TRX report? The xsd schema has a generic Category field. How these categories are transported around with which trait name seems sort of irrelevant, but if you want to use a Microsoft trx defined standard, you sort of have to adhere to that, or request their loggers have a more abstract way to define the various traits and their meaning.,

@OsirisTerje
Copy link

@dotMorten This code line https://github.com/Microsoft/vstest/blob/0341da456744f78bba8ff2a25c1cddfc89c87b08/src/Microsoft.TestPlatform.Extensions.TrxLogger/Utility/Converter.cs#L51 looks hardcoded to MSTest to me. The NUnit3TestAdapter doesn't write to the trx file, that is all up to vstest, it only provides the information, and the category type name is marking it as a category. There is no generic type name for the category on that side .

@nohwnd
Copy link
Member

nohwnd commented Jul 9, 2024

This is a new feature and won't be implemented, we are focusing on adding new features to Testing.Platform instead. https://aka.ms/testingplatform

@nohwnd nohwnd closed this as not planned Won't fix, can't repro, duplicate, stale Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests