【问题标题】:azure pipeline No test result files were found天蓝色管道没有找到测试结果文件
【发布时间】:2021-08-07 01:38:18
【问题描述】:

我有一个 azure 管道来构建 c# 项目并将其发布到 docker 映像。 一切正常,但今天我想添加一个单元测试这个管道。

所以我为它添加了任务。

如下:

  - task: UseDotNet@2
    inputs:
      packageType: 'sdk'
      version: '5.x'

- task: DotNetCoreCLI@2
    displayName: 'DotNet - Restore'
    inputs:
      command: 'restore'
      projects: $(project)
      noCache: true
      versioningScheme: 'off'
      vstsFeed: 'feed'

  - task: DotNetCoreCLI@2
    displayName: "Run unit tests - $(Build.BuildNumber)"
    inputs:
      command: 'test'
      arguments: '--no-build --configuration $(Build.BuildNumber)'
      projects: 'path/to/Tests.csproj'
      publishtestResults: true

  - task: DotNetCoreCLI@2
    name: 'DotnetPublish'
    displayName: 'dotnet - Publish'
    inputs:
      command: 'publish'
      projects: $(project)
      arguments: '-o publish/projectapi -c release'
      modifyOutputPath: false
      zipAfterPublish: false
      publishWebProjects: false

  - task: Docker@2
    name: 'dockerBuildAndPush'
    displayName: 'docker - Build & Push'
    inputs:
      repository: $(imageRepository)
      Dockerfile: $(dockerfilePath)
      containerRegistry: ${{ variables.dockerRegistryServiceConnection }}
      buildContext: ${{ variables.buildContext }}
      tags: |
        $(Build.BuildNumber)
        latest

当我在测试任务上运行管道时,不到 2 秒就返回了

##[warning]No test result files were found.

如果我前往测试选项卡,我会看到没有要显示的测试的消息。

我在管道配置中做错了吗?

非常感谢您的帮助

编辑: 有一些关于此的更新。该问题与我没有测试 csproj 的构建任务有关。 当我实现任务并运行管道时。我收到有关找不到 nuget 包(私有 nuget)的错误。在 devops 面板的 vsfeed 中,我可以看到该包存在,但由于某种原因管道失败,因为它没有看到该包。 有没有人遇到过这种情况并且知道解决方法?

【问题讨论】:

  • 测试 .csproj 是否包含在 $(project) var 中?
  • 不,不是。我必须包括它吗?因为我的测试,生成随机数据并检查结果。
  • 我对 AzurePipelines 没有太多经验,但我会加入它,看看是否可行。
  • 不,它不起作用。同样的问题。

标签: c# azure-devops azure-pipelines


【解决方案1】:

尝试从参数中删除--no-build。在运行构建之前,管道中没有任何内容。您可能还需要确保您的 dotnet restore 命令正在恢复测试项目的包。 (我无法判断$(project) 的恢复是否会)

【讨论】:

  • 非常感谢您的帮助和建议。现在正在编译吗。但我又回到了我一开始遇到的错误。我得到这些错误。 .dll is invalid. Please use the /help option to check the list of valid arguments. 与我恢复和构建的 csproj 相关。另一个错误是##[warning]No test result files were found.. 非常感谢您提供的任何帮助
  • 现在可以用了吗,我忘了删除--no-build。非常感谢我的朋友
猜你喜欢
  • 2017-08-14
  • 2019-03-18
  • 2021-01-03
  • 1970-01-01
  • 2020-09-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多