繁体   English   中英

无法运行NUnit测试

[英]Unable to run NUnit test

我安装了NUnit 2.6.1并试图在Windows 7 x64上运行一个简单的测试。 它会导致异常

尝试加载格式不正确的程序。 您可能正在尝试加载使用CLR的更高版本构建的程序集,而不是NUnit当前运行的版本(2.0.50727)或尝试将64位程序集加载到32位进程中。

这很奇怪,因为nunit.exe.config如下所示

  <?xml version="1.0" encoding="utf-8" ?> 
- <configuration>
- <!-- 
   The GUI only runs under .NET 2.0 or higher. The
   useLegacyV2RuntimeActivationPolicy setting only
   applies under .NET 4.0 and permits use of mixed 
   mode assemblies, which would otherwise not load 
   correctly.


  --> 
- <startup useLegacyV2RuntimeActivationPolicy="true">
- <!--  Comment out the next line to force use of .NET 4.0 
  --> 
- <!--  <supportedRuntime version="v2.0.50727" /> 
  --> 
  <supportedRuntime version="v4.0.30319" /> 
  </startup>
- <runtime>
- <!--  Ensure that test exceptions don't crash NUnit 
  --> 
  <legacyUnhandledExceptionPolicy enabled="1" /> 
- <!--  Run partial trust V2 assemblies in full trust under .NET 4.0 
  --> 
  <loadFromRemoteSources enabled="true" /> 
- <!--  Look for addins in the addins directory for now 
  --> 
- <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <probing privatePath="lib;addins" /> 
  </assemblyBinding>
  </runtime>
  </configuration>

这听起来不像NUnit的问题。 这听起来像您的单元测试程序集不是为32位进程构建的。 您确定您的单元测试组件是否为32位构建? 如果NUnit运行32位并且您的程序集是以64位(或不构建为任何CPU)构建的,那么您将遇到此问题。 调用应用程序确定程序集所需的位深度。 您不能在32位进程中使用64位dll,反之亦然。

我提到这个的唯一原因是因为你的问题说你正试图运行测试。 如果NUnit配置不正确,它甚至都不会启动。

暂无
暂无

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

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