简体   繁体   English

Azure Devops 无法运行 xUnit 测试

[英]Azure Devops Cant Run xUnit tests

I have an ASP.Net Core Web API application with unit tests built using xUnit.我有一个带有使用 xUnit 构建的单元测试的 ASP.Net Core Web API 应用程序。 I am currently using the .Net Core 2.1.4 SDK and have the Microsoft.AspNetCore.All nuget package installed in both the Web API and xUnit project.我目前正在使用 .Net Core 2.1.4 SDK,并且在 Web API 和 xUnit 项目中都安装了Microsoft.AspNetCore.All nuget 包。 I am able to build and run the Web API and the tests just fine on my local machine.我能够在我的本地机器上构建和运行 Web API 和测试。

The application builds just fine in Azure Devops, however I cannot get the tests to run.该应用程序在 Azure Devops 中构建得很好,但是我无法运行测试。

I am running the tests on Azure Devops using the Dotnet Test command.我正在使用 Dotnet Test命令在 Azure Devops 上运行Test I have the step configured like so:我的步骤配置如下:

测试配置

After the step sucessfully builds the tests project, I get the error:在该步骤成功构建测试项目后,我收到错误消息:

The specified framework 'Microsoft.AspNetCore.All', version '2.1.4' was not found. Test Run Aborted

Additionally the console tells me the following versions of Microsoft.AspNetCore.All are installed:此外,控制台告诉我安装了以下版本的Microsoft.AspNetCore.All

2.1.0 2.1.1 2.1.2 2.1.0 2.1.1 2.1.2

Do I need to set something up in Azure Devops that specifies which version of .Net Core my project requires?我是否需要在 Azure Devops 中设置一些东西来指定我的项目需要哪个版本的 .Net Core? If that is the case, why is the Web API/test project able to build even though they require 2.1.4?如果是这样,为什么 Web API/测试项目即使需要 2.1.4 也能够构建?

Try by run it as "Visual Studio Test" instead and in the "Test files" box add two rows for xUnit.尝试将其作为“Visual Studio 测试”运行,并在“测试文件”框中为 xUnit 添加两行。

**\bin\$(BuildConfiguration)\**\*test*.dll
!**\obj\**

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

It's working good for me.它对我很有用。

在此处输入图片说明

Otherwise take a look on Shinigami'a tutorial in: https://blog.bitscry.com/2019/03/21/running-xunit-tests-in-azure-devops/ but his "Test files" paths did not work for me.否则看看 Shinigami'a 教程: https : //blog.bitscry.com/2019/03/21/running-xunit-tests-in-azure-devops/但他的“测试文件”路径不起作用我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM