【发布时间】:2019-02-17 01:27:00
【问题描述】:
我在 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 任务
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
【问题讨论】:
-
显然
Microsoft.TestPlatform.TestHost和Microsoft.NET.Test.Sdk支持到.NetCoreApp Version=v1.0是这个问题吗? -
遇到同样的问题,有什么更新吗?我可以找到的关于该主题的所有文档都表明您应该在项目上执行
dotnet publish以解决问题,但是由于我正在尝试根据所有测试项目的构建输出运行测试,所以这不会看起来很实用(我猜你也在做同样的事情?) -
我在 github 上为此创建了一个问题:github.com/Microsoft/vstest/issues/1928
-
@WouterRoos 在您提出的上述问题中,答案指定为
dotnet publish。你能详细说明一下吗?我添加了我的build.yaml -
他们建议使用
dotnet publish发布所有网络核心测试项目,其中将包括使用 vstest 任务运行测试所需的所有必要二进制文件。我目前使用DotNetCoreCLI@2步骤,将command设置为publish,对projects参数使用minimatch 模式来捕获解决方案中的所有netcore 测试项目,并使用--no-build作为arguments,因为我的解决方案有那时已经建成。
标签: .net-core azure-devops azure-pipelines-release-pipeline