Moles v0.94导致测试忽略配置文件 [英] Moles v0.94 Causing Tests To Ignore Config File

查看:88
本文介绍了Moles v0.94导致测试忽略配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Moles v0.91至少一年了,每天编写和执行数百个测试.升级到v0.94后,在Moles主机下运行的测试将不再能够访问配置文件.这些测试几天前可以正常运行.这些测试中的每一个的错误消息都明确表明它们无法访问配置,例如找不到连接字符串. (是的,我知道好的单元测试不应访问数据库.请不要专注于此).

在同一项目中,访问配置但未在Moles主机下运行的测试可以正常运行.

有关如何解决此问题的任何建议?在Visual Studio 2008和2010中都出现,带有当前Service Pack以及.Net 3.5和.Net 4.0下.

更多详细信息:这是一个带有app.config的测试项目,在同一项目中,该项目可以正确读取不运行Moles主机的测试.使用Enterprise Library进行数据库和日志记录,两者均无法读取配置文件.

解决方案

似乎我忽略了

I've been using Moles v0.91 for at least a year, with hundreds of tests written and executed daily. After upgrading to v0.94, tests that run under the Moles host are no longer able to access the config file. These are tests that were otherwise working fine a few days earlier. The error message for each of these tests plainly indicates that they were unable to access the config, for example to find a connection string. (Yes, I know good unit tests should not be accessing the database. Please do not focus on that).

In the same project, tests that access the config but do not run under the Moles host are working perfectly.

Any suggestions for how to resolve this? Occurs in both Visual Studio 2008 and 2010, with current service packs and under both .Net 3.5 and .Net 4.0.

MORE DETAIL: This is a Test project with an app.config that is properly read, in the same project, for tests that do not run the Moles host. Using Enterprise Library for database and logging, both of which are failing to read the config file.

解决方案

It seems that I overlooked an MDSN forum post from 2010 where this was acknowledged as a bug. And it seems that no one is in a hurry to fix it. Thus, time to turn this into an opportunity to further improve the code through a little more abstraction, some careful refactoring, and more true-to-theory "unit" tests (that is, fix the problem with even more Moles).

这篇关于Moles v0.94导致测试忽略配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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