【问题标题】:Azure DevOps PublishTestResults not found junit cypress test result fileAzure DevOps PublishTestResults 未找到 junit cypress 测试结果文件
【发布时间】:2021-04-27 18:34:39
【问题描述】:

我正在尝试使用 Cypress 测试在 Azure DevOps 上设置管道。

本地测试输出文件已正确创建。

我正在使用 npx cypress 运行命令

我收到发布测试结果的错误/警告:

##[警告]没有找到匹配**/test-output-*.xml的测试结果文件。

这是我的 cypress.json 文件:

    {
    "reporter": "junit",
    "reporterOptions": {
      "mochaFile": "tests/test-output-[hash].xml",
      "toConsole": true,
      "attachments": true
    },
    "video": false,
    "pluginsFile": "cypress/plugins/index.js",
    "supportFile": "cypress/support/index.js"
   }

这里是 azure-pipelines.yml:

# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- develop

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
  displayName: 'npm install'

- script:
    npx cypress run
  displayName: 'Execute cypress tests'

- task: PublishTestResults@2
  displayName: "Publish Test Results"
  condition: always()
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: '**/test-output-*.xml'
    searchFolder: '$(System.DefaultWorkingDirectory)'

- task: PublishBuildArtifacts@1
  condition: always()
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

我试图做所有奇怪的事情,但没有任何帮助。 检查了所有 StackOverflow 主题,如下所示:

Azure DevOps test -xml not found after running the Cypress tests

Is there any way to show Cypress Test Results in Azure DevOps Test Results Tab?

Azure DevOps test -xml not found after running the Cypress tests

No test result files were found using search pattern '...\**\TEST-*.xml

Cypress Integration with DevOps

所有都希望根据赛普拉斯文档和博客等正确设置。

可能没有在 Azure 上创建测试输出文件?

也许有人有线索?

编辑: 我使用ls -al 命令检查,没有创建tests 文件夹。 但即使我在启动 cypress 之前使用 mkdir tests 创建它,在 cypress 作业之后该文件夹也是空的。 所以赛普拉斯没有创建测试输出报告。为什么在本地创建文件但在 Azure 上没有?

【问题讨论】:

    标签: junit azure-devops mocha.js cypress


    【解决方案1】:

    请按以下步骤检查:

    1. 将管道变量system.debug设置为true,再次运行管道。
    2. 步骤“Execute cypress tests”完成后,检查是否可以从控制台窗口的调试日志中获取更多故障排除详细信息。
    3. 您提到同样的 npx cypress run 命令可以在您的本地机器上正常工作,请尝试在您的本地机器上安装自托管代理来运行管道,看看问题是否仍然存在存在。

    如果问题仍然存在,为了我们进一步调查此问题,请与我们分享测试步骤的完整日志。

    【讨论】:

    • 抱歉,问题是我使用了不同的本地分支和不同的 Azure 构建......这就是它在本地工作的原因,因为在 azure 构建它的分支上 cypress.json 是空的.
    • @DuduA,很高兴你解决了这个问题。如果可能,您能否添加一个答案作为该主题的原因和解决方案的摘要?这可能会帮助更多在寻找答案时遇到类似问题的人。谢谢。
    【解决方案2】:

    刚刚遇到同样的问题。将我的工件下载任务设置在特定版本上,因此我从未使用正确的 cypress.config 文件获得新版本。更新了构建目标,现在一切正常。所以感谢@DuduA,我想我会回答它,这样更容易查看是否有人有同样的问题。

    【讨论】:

      【解决方案3】:

      请添加命令行任务以检查 cypress run 命令是否在哪个文件夹中运行。 我认为您可能在错误的文件夹中运行 cypress 命令。如果您提供正确的文件夹结构并在 cypress.json 文件所在的位置运行 cypress run 命令,该问题将得到解决。 同样在 cypress.json 文件中检查插件文件和支持文件的路径。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-07
        • 1970-01-01
        • 1970-01-01
        • 2013-02-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-28
        相关资源
        最近更新 更多