0

我有一些使用 NHibernate 和 SQLite 在内存中测试我的数据库组件的测试。测试在 Visual Studio 中运行良好,但是 MSTest.exe 控制台运行程序拒绝运行我的所有测试。控制台运行器由使用 TeamCity 运行所有测试的构建服务器使用,我在我的机器上使用 MSTest.exe 来查看本地控制台运行器也失败了。

我有这个内部异常:

NHibernate.HibernateException: Could not create the driver fromNHibernate.Driver.SQLite20Driver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider.  It may not be installed

对此的大多数答案包括将正确的参考程序集添加到 App.config 到 sqlite,但是测试项目是一个类库。

在我的测试项目中,我引用了以下程序集:

  • NHibernate 3.3.1.4000
  • System.Data.SQLite (x86, x64) 1.0.89.0
  • Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 10.0.0.0 (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0\,我更改了指向 v2.0 的默认引用文件夹,并且由于以下错误而不会在构建服务器上运行测试,尽管它在 Visual Studio 中仍然可以正常运行:

ClassInitialize 的签名错误。参数 1 的类型应为 Microsoft.VisualStudio.TestTools.UnitTesting.TestContext

我使用以下工具:

  • MSTest.exe (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe)
  • .NET 框架 4.0
  • 视觉工作室 2012

知道如何进行吗?谢谢 !

4

1 回答 1

0

好的,最后我使用 vstest.console.exe 控制台运行程序来执行测试,它可以工作。(不知道那里出了什么问题)如果您有兴趣将此跑步者与 Teamcity 结合,请阅读: http ://blog.dontpaniclabs.com/post/2013/06/13/TeamCity-Builds-with- the-Visual-Studio-2012-Test-Runner

于 2013-11-12T13:21:50.820 回答