MSpec在ReSharper下运行很好,但TD.NET抛出异常

时间:2011-01-25 22:06:16

标签: unit-testing resharper bdd testdriven.net mspec

尝试使用TD.NET运行mspec规范测试时,我一直在收到此异常。

------ Test started: Assembly: DesignRightWeb.Specs.dll ------

Error: Runner failure: System.Runtime.Serialization.SerializationException: Type is not         resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications,     Version=0.3.0.0, Culture=neutral, PublicKeyToken=null'.
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
   at     Machine.Specifications.Runner.Impl.AppDomainRunner.CreateRunnerAndUnloadAppDomain(String     runMethod, AppDomain appDomain, Assembly assembly, Object[] args) in d:\BuildAgent-    01\work\340c36596c29db8\Source\Machine.Specifications\Runner\Impl\AppDomainRunner.cs:line     81
Test 'T:DesignRightWeb.Specs.given_a_string_calculator' failed: Type is not resolved     for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications,     Version=0.3.0.0, Culture=neutral, PublicKeyToken=null'.
    System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null'.
    at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
    at Machine.Specifications.Runner.Impl.AppDomainRunner.CreateRunnerAndUnloadAppDomain(String runMethod, AppDomain appDomain, Assembly assembly, Object[] args)
    at Machine.Specifications.Runner.Impl.AppDomainRunner.RunMember(Assembly assembly, MemberInfo member)
    at Machine.Specifications.TDNetRunner.SpecificationRunner.RunMember(ITestListener testListener, Assembly assembly, MemberInfo member)
    at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
    at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()

0 passed, 1 failed, 0 skipped, took 1.12 seconds (MSpec).

我尝试直接从Github安装MSpec,并使用NuGet安装它。之后 - 在收到同样的异常时 - 我卸载了TD.NET并重新安装了TD.NET。仍然收到这个例外。

有什么想法吗?思考?溶液

2 个答案:

答案 0 :(得分:2)

您是否需要将MSpec测试运行器注册到TestDriven.NET?看看这篇文章可以帮到你:

http://eduncan911.com/blog/registering-mspec-runners-for-testdriven-net-on-windows-x64.aspx

答案 1 :(得分:1)

如果您之前注册过TD.Net亚军,请取消注册(可能需要一些注册表黑客攻击 - 请参阅InstallTDNetRunner.bat如何撤消)。

请确保运行TD.Net> = 2.24。将NuGet包添加到项目中并通过TD.Net运行测试。 NuGet包还包含您可能想要安装的更新的ReSharper运行器。

如果错误仍然存​​在,您很可能会在某处引用旧版本的MSpec。旧版本为0.3.0.0,而NuGet目前为0.4.7.0。

(我可能会补充一点 - 当你发布你的问题时,我们有一个由某人贡献的NuGet包。该软件包没有包含相应的TD.Net运行器。你描述的问题应该解决,因为我们有一个新的包含所有跑步者的NuGet包。)