MVC3,测试环境和开发应用程序之间的差异? [英] MVC3, Differences between Test environment and dev application?

查看:191
本文介绍了MVC3,测试环境和开发应用程序之间的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的临时数据库的创建和与每个测试删除,但已经非常小心,以确保它共享相同的设置为我的真实的数据库我的单元测试(争取= FALSE; multipleactiveresultsets = TRUE;等等)但一直在不断地运行到地方正在使用的TransactionScope MSDTC升级的问题。

I am using temporary database for my unit tests that are created and deleted with each test but have been very careful to ensure that it shares the same setup as my 'real' database (enlist=false;multipleactiveresultsets=true;etc) but have been constantly running into MSDTC escalation issues wherever TransactionScope is being used.

有关事务交换的TransactionScope后,我已经解决了MSDTC升级问题,直接运行到一个新的问题 - 事务完美的作品,因为我使用的网络浏览器的应用程序,但它与下面的错误单元测试失败:

After switching TransactionScope for Transaction I have solved the MSDTC escalation issue and run straight into a new problem - the transaction works perfectly as I use the application in the web browser, but it fails in unit testing with the following error:

的SqlConnection不支持并行事务。

SqlConnection does not support parallel transactions.

没有张贴吨code,已经没有其他人遇到那里的测试环境和开发环境出现不同的工作类似的问题?是否有任何一般之所以并行交易将在开发工作,而不是在单元测试模式?

Without posting tons of code, has anyone else run into similar problems where the test environment and dev environment appear to work differently? Is there any general reason why a parallel transaction would work in dev and not in unit test mode?

如果我不能模拟正是与我的测试中发生的事情又是什么在测试点呢?

If I cannot simulate exactly what is happening with my tests then what is the point in testing at all?

推荐答案

一大区别,我没有考虑到被我可能会使用其中的RenderAction 在视图中,因此调用比将测试,这也许可以解释 MSDTC /事务问题的更多的控制器动作。

One big difference that I failed to account for was where I may be using RenderAction in a view, and therefore calling more controller actions than the test would, which may explain MSDTC/Transaction issue.

这篇关于MVC3,测试环境和开发应用程序之间的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆