首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASP.NET集成测试-- TestDrive.net不会运行它们,其他测试人员将运行它们

ASP.NET集成测试-- TestDrive.net不会运行它们,其他测试人员将运行它们
EN

Stack Overflow用户
提问于 2011-10-20 20:31:48
回答 1查看 760关注 0票数 2

最近,在我将我的解决方案升级到had problems 4.0之后,我进行了集成测试--这个问题的答案是获取64位版本的System.Data.SQLite.dll。

我已经想好了,但我有一个相关的问题。当我使用Resharper时,我的集成测试会执行,但是当我使用TestDriven.NET testrunner时会引发异常:

代码语言:javascript
复制
Test 'MyApp.IntegrationTests.DataAccess.Providers.ContactFormSubmissionProviderTest.CanFetchContactFormSubmissionById' failed:
    System.TypeInitializationException : The type initializer for 'MyApp.DataAccess.NHibernate.SessionManager' threw an exception.
  ----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver.
  ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.
    at MyApp.DataAccess.NHibernate.SessionManager.OpenSession()
    DataAccess\Providers\ContactFormSubmissionProviderTest.cs(28,0): at MyApp.IntegrationTests.DataAccess.Providers.ContactFormSubmissionProviderTest.CanFetchContactFormSubmissionById()
    --HibernateException
    at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
    at NHibernate.Connection.ConnectionProvider.Configure(IDictionary`2 settings)
    at NHibernate.Connection.ConnectionProviderFactory.NewConnectionProvider(IDictionary`2 settings)
    at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
    at NHibernate.Cfg.Configuration.BuildSettings()
    at NHibernate.Cfg.Configuration.BuildSessionFactory()
    NHibernate\SessionManager.cs(18,0): at MyApp.DataAccess.NHibernate.SessionManager..cctor()
    --TargetInvocationException
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.Activator.CreateInstance(Type type)
    at NHibernate.Connection.ConnectionProvider.ConfigureDriver(IDictionary`2 settings)
    --HibernateException
    at NHibernate.Driver.ReflectionBasedDriver..ctor(String driverAssemblyName, String connectionTypeName, String commandTypeName)
    at NHibernate.Driver.SQLite20Driver..ctor()

图片:

我还在this link中尝试了这个解决方案,但没有帮助。如何从Testdriven.Net运行测试?

更新:

我的项目被设置为任何CPU,发布平台。

我的操作系统是Windows 7 64位.我已经链接到了x86和x64版本的SQLite。解释:

我的解决方案有几个项目- DataAccess、IntegrationTests、Core和UI。它们都是.net 4.0项目,除了UI之外,它们都是类库,这是一个MVC3.0项目。我使用的是nUnit 2.4.8.0。我的DataAccess层使用NHibernate。

  • 我的UI项目引用1.0.60.0 (否则我不能在VS2010中运行我的应用程序)。
  • My IntegrationTests项目引用1.0.74.0 (否则,我无法使用Resharper的DataAccess项目引用1.0.60.0运行测试,而
  • -我的核心项目不了解任何与数据库相关的信息。

1.0.60.0是x86,1.0.74.0是x64。

部署站点时,服务器需要x86。

更新2:

TestDriven.NET有一个选项,因为它在Tools -> Options -> TestDriven.NET下使用32位或64位进程,我将其更改为64位。现在,右键单击并选择"run Test“将很好地执行它们,但我仍然有”用NCover测试“或”用覆盖率测试“的相同问题,这正是我真正想要完成的。

EN

回答 1

Stack Overflow用户

发布于 2011-11-06 11:52:08

我想你可能已经回答了你自己的问题:)

在默认情况下,您提到的大多数运行程序都将在x86模式下运行,您必须找到特定的实例,您可以告诉某些运行程序(如TestDriven.net)使用x64在您的计算机上运行,但是现在您在NCover或覆盖率方面遇到了同样的问题。

因此,解决方案就是强迫项目在x86上进行构建。您的库将以x86为目标;ReSharper的运行程序将从解决方案中的构建配置中检测到这一点。因为您的目标生产机器是x86,所以没有问题。您可以在Win7 x64上运行x86目标程序集。

转到您的解决方案配置,并为您的每个项目选择“目标平台”为x86。从所有项目中引用x86 SQLite程序集。这就是我们如何在Win7x64开发机器上的几个项目上设置它,包括NCrunch、R#、dotCover,它们都表现良好。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7841881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档