gpt4 book ai didi

.net-core - 在 .Net Core 2.1 中运行集成测试时出现 VSTS 任务错误

转载 作者:行者123 更新时间:2023-12-03 08:01:47 25 4
gpt4 key购买 nike

我在 VSTS 2017 CD 任务中运行 API e2e 测试并在任务中遇到以下错误(vsTest - End2End 测试)

Unable to find d:\a\r1\a\Project\e2e\bin\Release\netcoreapp2.1\testhost.dll. Please publish your test project and retry.
Unable to find d:\a\r1\a\Project\e2e\obj\Release\netcoreapp2.1\Project.EndToEnd.Integration.Test.deps.json. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk".

我的 e2e 项目中有以下 nuget 包。

<PackageReference Include="FluentAssertions" Version="5.6.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="TestStack.BDDfy" Version="4.3.2" />
<PackageReference Include="TestStack.BDDfy.Xunit" Version="1.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.core" Version="2.4.1" />
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">

我的项目目标框架是.Net Core 2.1

根据 this我相信一切就绪。不确定缺少什么?

VSTS 任务

enter image description here

Build.yaml(部分)

- task: CopyFiles@2
displayName: "Copy Files to: $(Build.ArtifactStagingDirectory)"
inputs:
contents: "D:/a/1/s/src/xxx.EndToEnd.Integration.Tests/**"
targetFolder: $(Build.ArtifactStagingDirectory)

- task: DotNetCoreCLI@2
displayName: "dotnet e2e tests"
inputs:
command: publish
projects: $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests/xxx.EndToEnd.Integration.Tests.csproj
arguments : --no-build

- task: PublishBuildArtifacts@1
displayName: "Publish End-to-End Tests"
inputs:
artifactName: e2e
artifactType: container
pathToPublish: $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests

最佳答案

有两种方法可以处理这个问题。

  1. 发布您的项目。这可以确保测试 dll 和所有依赖项都放在一个文件夹中。您可以提供此已发布位置的路径并运行您的测试。

  2. 您可以使用 dotnet cli 任务。如果您使用的是 YAML 定义,请按如下方式添加任务:

    - task: DotNetCoreCLI@2
    displayName: 'dotnet test'
    inputs:
    command: test
    projects: '**/*.Tests/*.csproj'

引用:Dotnet CLI task

关于.net-core - 在 .Net Core 2.1 中运行集成测试时出现 VSTS 任务错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54729313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com