问题描述
我正在尝试通过将一些任务拆分为单独的作业以实现可扩展性来重构我的构建管道。
以下工作完美,测试找到并运行没有问题。
stages:
- stage: build_test_publish
displayName: Build
pool:
vmImage: "windows-latest"
variables:
solution: "**/SolutionName.sln"
buildPlatform: "Any CPU"
buildConfiguration: "Release"
jobs:
- job: build_publish_artifacts
displayName: "Build,test and publish artifacts"
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: "restore"
restoreSolution: "**/*.sln"
feedsToUse: "select"
vstsFeed: "xxx"
- task: VSBuild@1
inputs:
solution: "$(solution)"
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: "$(buildPlatform)"
configuration: "$(buildConfiguration)"
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
runInParallel: false
codeCoverageEnabled: true
testAssemblyVer2: |
**\*test*.dll
!**\ProjectName.IntegrationTests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
但是,像下面那样将其拆分后,我得到以下输出,其中找不到任何测试。
stages:
- stage: build_test_publish
displayName: Build,test and publish artifacts
pool:
vmImage: "windows-latest"
variables:
solution: "**/SolutionName.sln"
buildPlatform: "Any CPU"
buildConfiguration: "Release"
jobs:
- job: build
displayName: "Build"
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
command: "restore"
restoreSolution: "**/*.sln"
feedsToUse: "select"
vstsFeed: "xxx"
- task: VSBuild@1
inputs:
solution: "$(solution)"
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: "$(buildPlatform)"
configuration: "$(buildConfiguration)"
- job: test
displayName: Run unit tests
dependsOn: build
steps:
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
runInParallel: false
codeCoverageEnabled: true
testAssemblyVer2: |
**\*test*.dll
!**\ProjectName.IntegrationTests.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
Starting: VSTest
==============================================================================
Task : Visual Studio Test
Description : Run unit and functional tests (Selenium,Appium,Coded UI test,etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest,xUnit,NUnit,Chutzpah (for JavaScript tests using QUnit,Mocha and Jasmine),etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
Version : 2.170.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/vstest
==============================================================================
SystemVssConnection exists true
SystemVssConnection exists true
Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : D:\a\1\s
Action when minimum tests threshold not met : donothing
Minimum tests expected to be run: 0
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation with version [16.0,17.0).
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : true
Diagnostics enabled : false
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
Source filter: **\*test*.dll,!**\ProjectName.IntegrationTests.dll,!**\*TestAdapter.dll,!**\obj\**
##[warning]No test sources found matching the given filter '**\*test*.dll,!**\obj\**'
Finishing: VSTest
为什么会发生这种情况,我应该改变或重新思考什么?
**编辑 似乎可能是因为每个作业都使用自己的代理来运行其作业中的任务。
我仍然想知道这样的事情是否可行,以便使用不同的环境变量开始测试运行
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)