简体   繁体   English

NUnit无法构建测试 - 未发现任何测试

[英]NUnit fail to build test - No Tests discovered

I am working on selenium web driver project. 我正在研究selenium web driver项目。 I was able to built tests in Test Explorer and execute. 我能够在Test Explorer构建测试并执行。

At once I am getting following errors when rebuilding the solution. 在重建解决方案时,我立即遇到以下错误。

Unit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
NUnit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in  C:\..\CustomerTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Attempt to load assembly with unsupported test framework in  C:\..\LoginTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\..\CustomerTest.exe
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\..\LoginTest.exe
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
========== Discover test finished: 0 found (0:00:02.5558095) ==========

I have changed the default processor architecture in to X64 , but issue not resolved. 我已将默认处理器体系结构更改为X64 ,但问题未解决。

Please help me to resolve this issue. 请帮我解决这个问题。

Thank you. 谢谢。

I had this problem just today for some odd reason, because I didnt change anything in the meantime and it worked before. 我出现这个问题只是因为一些奇怪的原因,因为在此期间我没有改变任何东西而且之前有效。

Fixed it by: Project-> [YourProjectName].properties -> Build -> Platform target: "Any CPU" -> Untick "Prefer 32-Bit" 修复它:Project-> [YourProjectName] .properties - > Build - > Platform target:“Any CPU” - > Untick“Prefer 32-Bit”

It seems to be the same problem like here: Visual Studio FsUnit test setup - Exception NUnit.Engine.NUnitEngineException So installing Adapter Version 3.0.10 should solve your problem. 这似乎是同样的问题: Visual Studio FsUnit测试设置 - 异常NUnit.Engine.NUnitEngineException所以安装适配器版本3.0.10应该可以解决您的问题。 At least it did for me. 至少它对我有用。

You can follow the issue on github . 你可以在github上关注这个问题。

I faced the same problem with NUnit 3 Test Adapter (version 3.2.0). 我遇到了与NUnit 3测试适配器(版本3.2.0)相同的问题。 I uninstalled it and tried NUnit Test Adapter Version 2.0.0.0. 我卸载它并尝试了NUnit Test Adapter Version 2.0.0.0。 That solved the problem for me. 这解决了我的问题。

I used the VS > Tools > Extensions and Updates to install/uninstall the adapter. 我使用VS>工具>扩展和更新来安装/卸载适配器。

My VS project is set to build for Platform x86 and I was using VS Ultimate 2013 Update 5. 我的VS项目设置为Platform x86构建,我正在使用VS Ultimate 2013 Update 5。

I had the same problem with my .NET Core 2.0 project with NUnit 3.9 in Visual Studio 2017 and was stuck with this for quite some time. 我在Visual Studio 2017使用NUnit 3.9 .NET Core 2.0项目遇到了同样的问题,并且已经坚持了很长一段时间。 None of the solutions suggested in other related questions worked. 其他相关问题中提出的解决方案都没有奏效。

Then I figured out from this link that a class library with target .NET Standard does not work. 然后我从这个链接中发现,目标.NET Standard类库不起作用。 The test project has to target .NET Core . 测试项目必须以.NET Core为目标。 Also, Microsoft.NET.Test.Sdk NuGet is required. 此外,还需要Microsoft.NET.Test.Sdk NuGet。

So, the steps are 所以,步骤是

  1. Make sure that the test project targets .NET Core 确保测试项目以.NET Core目标
  2. Install latest NUnit NuGet (I used 3.9) 安装最新的NUnit NuGet(我用3.9)
  3. Install corresponding NUnitAdapter NuGet (I used NUnit3Adapter) 安装相应的NUnitAdapter NuGet(我使用的是NUnit3Adapter)
  4. Install Microsoft.NET.Test.Sdk NuGet 安装Microsoft.NET.Test.Sdk NuGet

Re-build and your tests will appear in Test Explorer in Visual Studio. 重新构建,您的测试将出现在Visual Studio中的测试资源管理器中。

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

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