我试图通过将一些任务拆分成单独的作业来重构我的构建管道以实现可扩展性。
以下工作完美,找到并运行测试没有问题。
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,!**\ProjectName.IntegrationTests.dll,!**\*TestAdapter.dll,!**\obj\**'
Finishing: VSTest
为什么会发生这种情况,我应该改变或重新考虑什么?
**编辑似乎可能是因为每个作业都使用它自己的代理来运行其作业中的任务。
我仍然想知道这样的事情是否可以使用不同的环境变量开始测试运行