【发布时间】:2020-08-05 01:14:15
【问题描述】:
CI 流水线大约需要 50 分钟才能完成,并且大部分时间都用于测试。有大量的单元测试和数据驱动测试。已决定并行运行测试,并且该方法基于此文档 Run Tests In Parallel In Build Pipelines
想法是将管道分成 3 个作业
Build Job:构建二进制文件并将它们发布到工件 名称预删除。
测试作业:下载工件预放置,提取文件,使用 VSTest@2 任务并行运行测试
发布作业:将工件发布到 drop(用于发布管道)。
不确定我是否能够将我的想法转化为 .yml。
测试作业
- job : 'TestJob'
pool:
vmImage: windows-latest
strategy:
parallel: 2
dependsOn: 'BuildJob'
steps:
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'predrop'
downloadPath: '$(System.ArtifactsDirectory)'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/predrop/predrop.zip'
destinationFolder: '$(System.ArtifactsDirectory)/predrop/Extpredrop'
- task: VSTest@2
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*tests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.ArtifactsDirectory)'
vstestLocationMethod: 'location'
vstestLocation: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\'
otherConsoleOptions: '/platform:x64 /Framework:.NETCoreApp,Version=v3.1'
问题在于 VSTest 任务识别并运行一些测试,但在其他测试中出错,并在某些测试中出现以下错误
System.BadImageFormatException : Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=3.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Format of the executable (.exe) or library (.dll) is invalid.
第一个作业的二进制文件已生成 Microsoft.Extensions.Logging.Abstractions.dll 作为工件的一部分。
【问题讨论】:
-
一切看起来都很好,所以它可能是一个单一的配置。如果您与我们分享您的 YAML 文件会很方便。
-
为测试作业更新了 yaml
标签: .net-core azure-devops xunit.net vstest microsoft-extensions-logging