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

Add support for testcase.attachments #51

Conversation

bryanbcook
Copy link
Contributor

@bryanbcook bryanbcook commented Feb 28, 2024

This PR introduces extends testcase with an attachments array. Currently supported for the following implementations:

  • Cucumber
  • JUnit
  • MSTest
  • NUnit
  • XUnit (not supported)

A few implementation notes:

  • JUnit:

    Based on the Jenkins Plugin Attachment plugin which inspects the <system.out> property in the XML for the following syntax: [[ATTACHMENT|/absolute/path/tofile.png]]

    I have confirmed that the azure-devops build-agent test publisher uses this convention as well. The path can be an absolute path or relative to the location of the test results xml.

    image

  • MSTest:

    Attachments appear in the xml under the test result for a given execution:

    <TestRun name="username_machinename 2024-02-28 17:25:00">
      <Results>
        <UnitTestResult executionId="xxxx" testId="yyyy">
          <ResultFiles>
            <ResultFile path="machinename/file.txt" />
          </ResultFiles>
         </UnitTestResult>
      </Results>
      <TestDefinitions>
        <UnitTest id="yyyy">
        </UnitTest>
      </TestDefinitions>
    </TestRun>

    Calls to TestContext.AddResultFile(filename) copies the file into a special folder per test, which is a combination of TestRun name + Test Execution id + Machine Name, relative to the location of the test results xml file.

    testResults.trx
    \<username>_<machinename>_<timestamp>
      \In
        \<testexecutionid>
          \<machinename>
            file.txt
    

    The test-parser mstest implementation expands out the relative path from the XML into a value that can be resolved at runtime relative to the test results xml file.

  • NUnit:

    Very straight-forward as NUnit only accepts absolute paths.

Addresses:

@ASaiAnudeep ASaiAnudeep merged commit a1ba45e into test-results-reporter:main Feb 29, 2024
6 checks passed
@bryanbcook bryanbcook deleted the feature/49-attachment-support branch February 29, 2024 18:22
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.

None yet

2 participants