【问题标题】:Azure Pipeline VSTest@2 Task thinks project that ends with "Tester" is a test projectAzure Pipeline VSTest@2 Task 认为以“Tester”结尾的项目是测试项目
【发布时间】:2021-06-14 13:00:14
【问题描述】:

我的 YAML:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'


variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

我有一个名为 DatabaseModeler Tester 的 csproj:

当管道运行时,我收到以下错误:

此项目不是测试项目,也没有任何测试依赖项。

【问题讨论】:

    标签: c# asp.net-core azure-devops azure-pipelines


    【解决方案1】:

    VsTest 任务的默认值为:

            {
                "name": "testAssemblyVer2",
                "type": "multiLine",
                "label": "Test files",
                "defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
                "required": true,
                "helpMarkDown": "Run tests from the specified files.<br>Ordered tests and webtests can be run by specifying the .orderedtest and .webtest files respectively. To run .webtest, Visual Studio 2017 Update 4 or higher is needed. <br><br>The file paths are relative to the search folder. Supports multiple lines of minimatch patterns. [More information](https://aka.ms/minimatchexamples)",
                "groupName": "testSelection",
                "properties": {
                    "rows": "3",
                    "resizable": "true"
                },
                "visibleRule": "testSelector = testAssemblies"
            },
    

    https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/VsTestV2/task.json#L72

    请注意,该任务将拾取名称中包含“test”的任何程序集。

                "defaultValue": "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**",
    

    在 VsTest2 任务上设置 testAssemblyVer2 属性将允许您选择正确的测试程序集。

    - task: VSTest@2
      inputs:
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
        testAssemblyVer2: "**\\*test*.dll\n!**\\*TestAdapter.dll\n!**\\obj\\**\n!**\Tester*.dll",
    

    在这种情况下,我为 Tester*.dll 添加了一个特定的排除项:\n!**\Tester*.dll,但您也可以创建一个更具体的规则来根据您的解决方案的文件夹结构选择您的测试程序集,例如当您的测试都位于tests文件夹:

    "**\\tests\\*test*.dll"
    

    【讨论】:

      猜你喜欢
      • 2023-01-08
      • 2019-12-06
      • 2018-12-02
      • 1970-01-01
      • 1970-01-01
      • 2014-10-14
      • 2015-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多