簡體   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