Azure DevOps 无法运行 xUnit 测试。

4
我有一个ASP.Net Core Web API应用程序,使用xUnit编写单元测试。我目前正在使用.Net Core 2.1.4 SDK,并在Web API和xUnit项目中安装了Microsoft.AspNetCore.All nuget包。我能够在本地机器上构建和运行Web API和测试。
应用程序在Azure Devops中构建得很好,但是我无法让测试运行。
我正在使用Dotnet Test命令在Azure Devops上运行测试。我已经配置了步骤,如下所示:

Test configuration

在成功构建测试项目之后,我遇到了以下错误:The specified framework 'Microsoft.AspNetCore.All', version '2.1.4' was not found. Test Run Aborted。此外,控制台告诉我已安装以下版本的Microsoft.AspNetCore.All

2.1.0 2.1.1 2.1.2

我需要在Azure Devops中设置某些内容来指定我的项目需要哪个版本的.Net Core吗?如果是这样,为什么Web API /测试项目需要2.1.4,但仍能够构建?
1个回答

1
尝试以“Visual Studio Test”的形式运行它,并在“测试文件”框中添加两行xUnit。
**\bin\$(BuildConfiguration)\**\*test*.dll
!**\obj\**

!**\bin\$(BuildConfiguration)\**\xunit.runner.visualstudio.testadapter.dll
!**\bin\$(BuildConfiguration)\**\xunit.runner.visualstudio.dotnetcore.testadapter.dll

它对我很有效。

enter image description here

否则请参考Shinigami在https://blog.bitscry.com/2019/03/21/running-xunit-tests-in-azure-devops/中的教程,但他的“测试文件”路径对我无效。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接