简体   繁体   English

Azure devops - 在网络核心/模板项目之外找不到 NUnit 测试

[英]Azure devops - NUnit tests not found when outside of a netcore/template project

I followed the tutorials in the docs for azure devops with regards to running Selenium tests as part of the build.我按照 azure devops 文档中的教程,将 Selenium 测试作为构建的一部分运行。

My local tests run fine with the browsers I have webdrivers installed for, but when the VSTest task runs, it doesn't unpack any tests from anything under NUnit attributes.我的本地测试在我安装了 webdrivers 的浏览器上运行良好,但是当 VSTest 任务运行时,它不会从 NUnit 属性下的任何内容中解压缩任何测试。

Now a few things to point out with my project structure:现在要指出我的项目结构的几件事:

  1. The test project started out as a basic Visual Studio 2017 Unit Test template, with MS Test.测试项目最初是一个基本的 Visual Studio 2017 单元测试模板,带有 MS 测试。
  2. I preferred NUnit, so I am writing/rewriting the tests using that framework instead of the MSTest it was created with.我更喜欢 NUnit,所以我使用该框架而不是创建它的 MSTest 来编写/重写测试。

My current azure devops pipeline config:我当前的 azure devops 管道配置: 天蓝色 devops 管道

Working local tests setup:工作本地测试设置:

在此处输入图像描述 在此处输入图像描述

Now, I can easily add a new project using the NUnit template which for whatever reason allows the azure build to see these tests, but that causes my project structure to change and it defaults to netcoreapp2.1 instead of 4.6, and then the azure build can't find all sorts of stuff.现在,我可以使用 NUnit 模板轻松添加一个新项目,无论出于何种原因,它都允许 azure 构建看到这些测试,但这会导致我的项目结构发生变化,它默认为 netcoreapp2.1 而不是 4.6,然后是 azure 构建各种东西都找不到。

Please follow the below steps may it resolve your issue请按照以下步骤操作可能会解决您的问题

  • There is no need to add TestAdapter.dll in Test files无需在测试文件中添加 TestAdapter.dll
  • uncheck "Test mix contains UI tests"取消选中“测试组合包含 UI 测试”
  • Select test platform using "version" as "Installed by Tools Installer" Select 测试平台使用“version”作为“Installed by Tools Installer”

or或者

You might need to search the test dll into $(System.DefaultStagingDirectory) folder.您可能需要在 $(System.DefaultStagingDirectory) 文件夹中搜索测试 dll。 sometimes azure agent place the dlls in staging directory instead of defaultworkingdirectory.有时 azure 代理将 dll 放在暂存目录而不是默认工作目录中。

When adding a new NUnit project by the visual studio template like so当像这样通过 Visual Studio 模板添加新的 NUnit 项目时在此处输入图像描述 It defaults the framework version to netcoreapp2.1它默认框架版本为 netcoreapp2.1 在此处输入图像描述

If I change this to my build framework (net461), although the build states the same "These dlls will be skipped" message, the NUnit3Adapter is somehow now recognized and picks up the NUnit tests:如果我将其更改为我的构建框架(net461),尽管构建声明相同的“这些 dll 将被跳过”消息,但 NUnit3Adapter 现在以某种方式被识别并获取 NUnit 测试: 在此处输入图像描述

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

相关问题 在 Azure DevOps 中对失败的 NUnit Selenium 测试进行故障排除 - Troubleshoot failing NUnit Selenium tests in Azure DevOps 在 Azure DevOps 上显示 NUnit 测试代码覆盖率 - Displaying NUnit tests code coverage on Azure DevOps 在 Azure DevOps 上构建 docker 容器时找不到项目 - Project not found when build docker container on Azure DevOps Azure Devops Visual Studio 测试任务无法发现具有 TestCaseSource 属性的 Nunit 测试 - Azure Devops Visual Studio Tests task cannot discover Nunit tests with the TestCaseSource attribute 如何仅在 azure devops CI env 但不在本地运行一些 NUnit 测试 - How to run some NUnit tests only in azure devops CI env but not locally Azure管道未运行NUnit测试 - Azure pipeline not running NUnit tests 具有堆栈的项目的 Azure DevOps 管道任务:selenium、c#、Nunit、边缘浏览器 - Azure devops pipeline tasks for a project with stack: selenium, c#, Nunit, edge browser Azure DevOps Pipeline 无法找到来自其他项目的 DLL - Azure DevOps Pipeline Fails DLL From Other Project Not Found Azure DevOps:解决多个.Net框架时测试失败 - Azure DevOps: tests failing when addressing multiple .Net frameworks 在NUnit Parameterised测试中找不到合适的构造函数 - No suitable constructor was found in NUnit Parameterised tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM