1

我是 Jest 的新手,我正在尝试使用jest-trx-results-processor为 Jest 生成 trx 文件(以在 azure ADO 中发布结果) 。

我能够生成 trx,但在将结果文件添加到测试失败时遇到了困难。

现在它只创建没有 ResultFile 的 UnitTest 节点,例如:

<UnitTestResult executionId="df9fd2e3-5889-4c60-9019-583cd48bf821" testId="3a7d9eab-0d0a-02bc-d094-3409dbb19e06" testName="TestMethod3" computerName="name-Z2" duration="00:00:00.0277049" startTime="2021-03-12T12:21:45.2193871+05:30" endTime="2021-03-12T12:21:45.2473877+05:30" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="df9fd2e3-5889-4c60-9019-583cd48bf821">
  <Output>
    <StdOut>TestContext.TestName='TestMethod3'  static _testContext.TestName='TestMethod1'</StdOut>
    <ErrorInfo>
      <Message>Assert.IsTrue failed. </Message>
      <StackTrace>   at UnitTestProject1.UnitTest1.TestMethod3() in C:\Users\name\source\repos\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 33</StackTrace>
    </ErrorInfo>
  </Output>
  
</UnitTestResult>

但我想要下面的东西:

<UnitTestResult executionId="df9fd2e3-5889-4c60-9019-583cd48bf821" testId="3a7d9eab-0d0a-02bc-d094-3409dbb19e06" testName="TestMethod3" computerName="name-Z2" duration="00:00:00.0277049" startTime="2021-03-12T12:21:45.2193871+05:30" endTime="2021-03-12T12:21:45.2473877+05:30" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="df9fd2e3-5889-4c60-9019-583cd48bf821">
  <Output>
    <StdOut>TestContext.TestName='TestMethod3'  static _testContext.TestName='TestMethod1'</StdOut>
    <ErrorInfo>
      <Message>Assert.IsTrue failed. </Message>
      <StackTrace>   at UnitTestProject1.UnitTest1.TestMethod3() in C:\Users\name\source\repos\UnitTestProject1\UnitTestProject1\UnitTest1.cs:line 33&#xD;</StackTrace>
    </ErrorInfo>
  </Output>
  **<ResultFiles>
    <ResultFile path="MachineName-Z2\IMG-20210309-WA0002.jpg" />
  </ResultFiles>**
</UnitTestResult>

谁能帮助我如何使用jest-trx-results-processor在 trx 中获取 ResultFiles 节点。?

4

0 回答 0