【问题标题】:NUnit fail to build test - No Tests discoveredNUnit 无法构建测试 - 未发现测试
【发布时间】:2018-01-05 01:36:05
【问题描述】:

我正在开发selenium 网络驱动程序项目。我能够在Test Explorer 中构建测试并执行。

我在重建解决方案时立即遇到以下错误。

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) ==========

我已将默认处理器架构更改为 X64,但问题未解决。

请帮我解决这个问题。

谢谢。

【问题讨论】:

  • 您能给我们看看您的配置管理器窗口吗?菜单 -> 构建 -> 配置管理器...
  • 我建议,将您的程序集构建为任何 CPU,对我来说,您的测试主机似乎配置为 X86。
  • 我的配置管理器平台已设置为任何 CPU。抱歉,我无法添加屏幕截图。
  • 项目 --> CustomerTest,配置 -> 调试,平台 -> 任何 CPU。
  • 任何人都可以告诉我为什么这个“尝试加载带有不受支持的测试框架的程序集”消息给出?这和 Nunit 版本有关吗?

标签: c# selenium nunit


【解决方案1】:

由于某种奇怪的原因,我今天遇到了这个问题,因为在此期间我没有进行任何更改,并且它之前有效。

通过以下方式修复它:项目-> [YourProjectName].properties -> 构建 -> 平台目标:“任何 CPU”-> 取消勾选“首选 32 位”

【讨论】:

  • 我也试过这个方法。但最终它在安装 TestAdapter 3.0.10 后工作。谢谢。
  • 取消首选 x32 位处理器解决了所有问题。谢谢。
【解决方案2】:

这似乎是同样的问题:Visual Studio FsUnit test setup - Exception NUnit.Engine.NUnitEngineException 所以安装适配器版本 3.0.10 应该可以解决您的问题。至少对我有用。

您可以在github关注问题。

【讨论】:

  • 感谢您的回答。它也对我有用。我安装了 VSTestAdapter 3.0.10。问题已解决。再次感谢。
【解决方案3】:

我在使用 NUnit 3 测试适配器(版本 3.2.0)时遇到了同样的问题。我卸载了它并尝试了 NUnit 测试适配器版本 2.0.0.0。这为我解决了问题。

我使用 VS > Tools > Extensions and Updates 来安装/卸载适配器。

我的 VS 项目设置为针对 Platform x86 构建,我使用的是 VS Ultimate 2013 Update 5。

【讨论】:

    【解决方案4】:

    我的.NET Core 2.0 项目与NUnit 3.9Visual Studio 2017 中遇到了同样的问题,并且被这个问题困扰了很长时间。其他相关问题中建议的解决方案均无效。

    然后我从 this 链接中发现目标为.NET Standard 的类库不起作用。测试项目必须针对.NET Core。此外,Microsoft.NET.Test.Sdk NuGet 是必需的。

    所以,步骤是

    1. 确保测试项目以.NET Core为目标
    2. 安装最新的NUnit NuGet(我用的是3.9)
    3. 安装对应的NUnitAdapterNuGet(我用的是NUnit3Adapter)
    4. 安装Microsoft.NET.Test.Sdk NuGet

    重新构建,您的测试将出现在 Visual Studio 的 Test Explorer 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-16
      相关资源
      最近更新 更多