VSTS错误:找不到与模式匹配的测试程序集

时间:2018-12-25 10:57:30

标签: azure-devops azure-pipelines-release-pipeline

我计划使用VSTS在夜间进行端到端测试。是否有任何指导性文件或示例计划说明如何实现此目的。

基本上,我们在VSTS中有API项目,在主要解决方案中有“端到端”测试项目。因此,我们希望在一夜之间进行这些测试。所有其他测试均作为构建的一部分运行,但不是E2E,因为它应在部署后运行。

这是build.yaml

resources:
- repo: self
queue:
  name: Hosted VS2017
  demands: 
  - vstest
  - msbuild
  - visualstudio

variables:
  BuildPlatform: 'any cpu'
  BuildConfiguration: 'release'
steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs: 
    versionSpec: 4.4.1


- task: NuGetCommand@2
  displayName: 'NuGet restore'

- task: VSBuild@1
  displayName: 'Build solution'
  inputs:
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(Build.ArtifactStagingDirectory)\app.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: powershell@2
  inputs:
    targetType: filePath
    filePath: deploy/lib/GetSwaggerByExe.ps1
    arguments: '-RootDirectory "src/SwaggerGenerator"  -OutputFile "deploy/swagger/swagger.json" '
  displayName: 'Create Swagger file'

- task: VSTest@2
  displayName: 'Test Assemblies'
  inputs:
    testAssemblyVer2: |
     **\$(BuildConfiguration)\*test*.dll
     !**\obj\**
     !**\*\*.EndToEnd.Integration.Tests*.dll
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'

- task: PublishTestResults@2
  displayName: 'Publish API Test Results'
  inputs:
    testResultsFormat: VSTest
    testResultsFiles: '**/*.trx'

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    PublishSymbols: false
  continueOnError: true

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/app.zip'
    ArtifactName: app

- task: PublishBuildArtifacts@1
  displayName: 'Publish deploy scripts'
  inputs:
    PathtoPublish: deploy

    ArtifactName: deploy

我在CD中有以下任务

VSTS CD

这是因为上述任务步骤中的test files参数中的路径不正确。如果是这样,如何找出正确的路径?我也引用了下面的链接,尽管没有运气。

构建日志

Project "D:\a\1\s\src\XXXXSearch.Api.sln" (1) is building "D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\XXXSearch.EndToEnd.Integration.Tests.csproj" (6) on node 1 (default targets).
2018-12-23T09:48:50.2267347Z PrepareForBuild:
2018-12-23T09:48:50.2267390Z   Creating directory "bin\Release\".
2018-12-23T09:48:50.2269510Z   Creating directory "obj\Release\".

 Creating "D:\a\1\s\src\XXXXSearch.EndToEnd.Integration.Tests\obj\Release\XXXSearch.EndToEnd.Integration.Tests.csproj.CopyComplete" because "AlwaysCreate" was specified.
2018-12-23T09:48:50.4678280Z _CopyAppConfigFile:
2018-12-23T09:48:50.4678368Z   Copying file from "app.config" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll.config".
2018-12-23T09:48:50.4686244Z CopyFilesToOutputDirectory:
2018-12-23T09:48:50.4686316Z   Copying file from "obj\Release\XXXSearch.EndToEnd.Integration.Tests.dll" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll".
2018-12-23T09:48:50.4691372Z   XXXSearch.EndToEnd.Integration.Tests -> D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\bin\Release\XXXSearch.EndToEnd.Integration.Tests.dll
2018-12-23T09:48:50.4693481Z   Copying file from "obj\Release\XXXSearch.EndToEnd.Integration.Tests.pdb" to "bin\Release\XXXSearch.EndToEnd.Integration.Tests.pdb".
2018-12-23T09:48:50.4755662Z Done Building Project "D:\a\1\s\src\XXXSearch.EndToEnd.Integration.Tests\XXXSearch.EndToEnd.Integration.Tests.csproj" (default targets)

build.yaml文件中添加了以下任务

- task: CopyFiles@2
  inputs:
    contents: D:/a/1/s/src/XXX.SiteSearch.EndToEnd.Integration.Tests/bin/Release/XXX.SiteSearch.EndToEnd.Integration.Tests.dll
    targetFolder: $(Build.ArtifactStagingDirectory)

- task: PublishBuildArtifacts@1 
  displayName: 'Publish E2E Artifact' 
  inputs: 
    PathtoPublish: 'D:/a/1/a/src/XXX.SiteSearch.EndToEnd.Integration.Tests/bin/Release/XXX.SiteSearch.EndToEnd.Integration.Tests.dll' 
    ArtifactName: e2e

Solution-1

Solution-2

Solution-3

1 个答案:

答案 0 :(得分:2)

查看您要发布的工件的任务定义:

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/app.zip'
    ArtifactName: app

- task: PublishBuildArtifacts@1
  displayName: 'Publish deploy scripts'
  inputs:
    PathtoPublish: deploy

您要在哪里发布测试程序集?答案:您不是。

如果您不将某些内容发布为工件,那么它将不会在您的发行版的下游发布。

解决方案是将测试程序集(以及其他任何相关文件)发布为单独的工件。