我在MonoDevelop下建立了一个简单的项目,并可以从那里成功地运行测试(*)。
当我尝试从命令行使用nunit-console.exe时,我会得到以下结果:
.../mono2/bin/Debug$ nunit-console mono2.exe
NUnit version 2.5.10.0
...
Runtime Environment -
OS Version: Unix 2.6.32.44
CLR Version: 2.0.50727.1433 ( 2.10.8.1 (Debian 2.10.8.1-1~dhx1~lucid1) )
ProcessModel: Default DomainUsage: Single
Execution Runtime: Default
Unhandled Exception:
System.ArgumentException: NUnit components for version 4.0.30319 of the CLR are not installed
...
如果我省略了重要的内容,请告诉我。
nunit-gui给出了相同的错误。nunit-gui有一个选项可以从2.0切换到4.0,但是当我尝试时,它再次给出相同的错误,因此不允许我更改它。
更多细节:Ubuntu 10.04,使用http://badgerports.org/lucid.html存储库,因此是Mono 2.10.8.1。
根据MonoDevelop中的项目选项,该项目设置为使用"Mono/.NET 4.0"。
更多信息:
/usr/bin/nunit-console包含此内容:
#!/bin/sh
exec /usr/bin/cli /usr/lib/nunit/nunit-console.exe "$@"
而 /usr/lib/nunit/ 目录包含:
3073 2011-03-14 18:13 nunit.exe.config
2598 2011-03-14 18:13 nunit-console.exe.config
23040 2012-02-29 10:19 nunit-console-runner.dll
4608 2012-02-29 10:19 nunit-console.exe*
76288 2012-02-29 10:19 nunit.uiexception.dll
259072 2012-02-29 10:19 nunit.uikit.dll
183808 2012-02-29 10:19 nunit-gui-runner.dll
4096 2012-02-29 10:19 nunit.exe*
而nunit-console.exe.config包含:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<!-- We need this so test exceptions don't crash NUnit -->
<legacyUnhandledExceptionPolicy enabled="1" />
<!-- Look for addins in the addins directory for now -->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib;addins"/>
</assemblyBinding>
<!--
The following <assemblyBinding> section allows running nunit under
.NET 1.0 by redirecting assemblies. The appliesTo attribute
causes the section to be ignored except under .NET 1.0
on a machine with only the .NET version 1.0 runtime installed.
If application and its tests were built for .NET 1.1 you will
also need to redirect system assemblies in the test config file,
which controls loading of the tests.
-->
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"
appliesTo="v1.0.3705">
<dependentAssembly>
<assemblyIdentity name="System"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Data"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Drawing"
publicKeyToken="b03f5f7f11d50a3a"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Forms"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Xml"
publicKeyToken="b77a5c561934e089"
culture="neutral"/>
<bindingRedirect oldVersion="1.0.5000.0"
newVersion="1.0.3300.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
*: 嗯,当我尝试使用更奇特的Nunit属性时,我遇到了问题;这是我试图解决的真正的问题,它导致了我上面描述的那个问题。然而,上面使用的exe只有两个简单的测试,在MonoDevelop中运行良好。