c# - VSTest-testAssemblies 代理未在 Azure Pipelines 中运行 NUnit 框架的类别搜索筛选器

标签 c# azure vstest

我在测试过滤条件中使用 TestCategory=CategoryA 在我的测试中,我保存了以下内容,并认为它应该是唯一的测试运行,但我获得了成功,并且没有运行任何测试。我尝试过 dotnet test 并在参数中使用相同的方法,但由于其他问题而失败。我可以让 dot net test 运行,而无需为 VS Test 代理添加任何参数,即使我不添加测试过滤条件,它似乎也不想运行。

        [Test]
    [Category("CategoryA")]
   
    public async Task ActivateDevice()

2022-02-18T20:14:54.5643568Z ##[section]开始:VsTest - testAssemblies 2022-02-18T20:14:54.5771277Z ============================================ ======================================= 2022-02-18T20:14:54.5771649Z 任务:Visual Studio 测试 2022-02-18T20:14:54.5772497Z 描述:使用 Visual Studio Test (VsTest) 运行器运行单元和功能测试(Selenium、Appium、编码 UI 测试等)。可以运行具有 Visual Studio 测试适配器的测试框架,例如 MsTest、xUnit、NUnit、Chutzpah(用于使用 QUnit、Mocha 和 Jasmine 的 JavaScript 测试)等。使用此任务(版本 2)可以将测试分布在多个代理上。 2022-02-18T20:14:54.5773342Z 版本:2.198.0 2022-02-18T20:14:54.5773587Z 作者:微软公司 2022-02-18T20:14:54.5773921Z 帮助:https://learn.microsoft.com/azure/devops/pipelines/tasks/test/vstest 2022-02-18T20:14:54.5774333Z ============================================ ======================================= 2022-02-18T20:14:55.5713320Z SystemVssConnection 存在 true 2022-02-18T20:14:55.5732257Z SystemVssConnection 存在 true 2022-02-18T20:14:55.5991193Z 使用 vstest.console.exe 运行程序运行测试。 2022-02-18T20:14:55.5991725Z ============================================ ============= 2022-02-18T20:14:55.5997078Z 测试选择器:测试组件 2022-02-18T20:14:55.5998382Z 测试过滤条件:null 2022-02-18T20:14:55.5999337Z 搜索文件夹:D:\a\r1\a 2022-02-18T20:14:55.6102675Z 未达到最低测试阈值时的操作:不做任何事情 2022-02-18T20:14:55.6103140Z 预计运行的最少测试:0 2022-02-18T20:14:55.6104476Z 选择用于测试执行的 VisualStudio 版本:最新 2022-02-18T20:14:55.6107744Z 尝试从版本为 [17.0,18.0) 的 Visual Studio 安装中查找 vstest.console。 2022-02-18T20:14:56.0357719Z 尝试从版本为 [17.0,18.0) 的 Visual Studio 构建工具安装中查找 vstest.console。 2022-02-18T20:14:56.0642271Z 尝试从版本为 [16.0,17.0) 的 Visual Studio 安装中查找 vstest.console。 2022-02-18T20:14:56.0884398Z 尝试从版本为 [16.0,17.0) 的 Visual Studio 构建工具安装中查找 vstest.console。 2022-02-18T20:14:56.1142098Z 尝试从版本为 [15.0,16.0) 的 Visual Studio 安装中查找 vstest.console。 2022-02-18T20:14:56.3498931Z 并行运行: false 2022-02-18T20:14:56.3500994Z 隔离运行: false 2022-02-18T20:14:56.3502074Z 自定义适配器的路径:null 2022-02-18T20:14:56.3504871Z 其他控制台选项:null 2022-02-18T20:14:56.3505911Z 启用代码覆盖率: false 2022-02-18T20:14:56.3510216Z 诊断已启用:假 2022-02-18T20:14:56.3519771Z SystemVssConnection 存在 true 2022-02-18T20:14:56.3697972Z 使用 vstest.console.exe 在本地运行测试 2022-02-18T20:14:56.3698460Z ============================================ =============== 2022-02-18T20:14:56.5771570Z 源过滤器:D:\a\r1\a/_Test.AppiumTest/AppiumTesting/AppiumTest 2022-02-18T20:14:56.5973322Z ##[警告]未找到与给定过滤器匹配的测试源

最佳答案

1.检查是否安装了以下最新软件包:

Microsoft.NET.Test.Sdk
MSTest.TestAdapter
MSTest.TestFramework
NUnit3TestAdapter

2. 正如 Marina Liu 所回答的,您可以将 VSO 中的 MSTest 或“Visual Studio Test”任务配置为在出现警告时失败:
a. 在 Visual Studio 测试任务之后添加 PowerShell 任务。

b. 然后通过 Timeline 获取 Visual Studio Test 任务构建信息:

c.按任务名称或任务显示名称搜索 Visual Studio 测试任务信息。

d.如果 VS 测试出现您指定的警告,则构建结果失败。

引用文献: How to Fix this C# issue No test matches the given testcase filter `FullyQualifiedName = , How can I configure MSTest to fail the unit test run on any warnings?Run NUnit tests in Azure DevOps pipeline

关于c# - VSTest-testAssemblies 代理未在 Azure Pipelines 中运行 NUnit 框架的类别搜索筛选器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71179665/

相关文章:

python - 无法在 vscode 中导入 azureml

c# - 从 VSTest.Console.exe 向单元测试传递参数或选项

c# - 为什么在 vstest.console.exe 中进行测试时,dotnet vstest 返回 "No test is available in"?

azure - 将同一文件同时上传到 Azure Blob 存储

c# - C#中的多线程压缩

c# - 判断对象是否是泛型基类的实例,任意泛型类型

c# - 查找字符串中最长的单词

vb.net - Azure 表,检索数据

c# - .Net c# VisualStudio 2017执行测试,vstest.console.exe命令行说没有可用的测试

c# - System.Windows.Forms.Form.WndProc 没有定义