关于VS2008单元测试中加载配置文件的问题

问题:
终于尝试在项目中应用单元测试,一开始一切都按部就班的进行,一切良好,点[运行].显示出错结果,仔细看了下,异常信息为
Test method XinGongShe.Membership.Test.AccountManagerTest.UpdateUserRankPointsTest threw exception:  System.TypeInitializationException: The type initializer for 'XinGongShe.Membership.MembershipDataProvider' threw an exception. --->  System.IO.FileNotFoundException: Could not find file 'E:\Developing\XinGongShe Framework Solution\TestResults\Administrator_HEX 2009-07-28 19_23_34\Out\XinGongShe.config'..

原来配置文件没有自动复制到对应的测试目录,单元测试的生成目录是临时的,所以也不能简单的复制剪贴.

解决方案: 手工添加配置文件(针对vs2008英文版)
  1. 双击 LocalTestRun.testrunconfig 文件
  2. 选择 deployment 选项
  3. 单击 Add
  4. 选择配置文件.
posted @ 2009-07-28 19:55  Hex  阅读(1653)  评论(0编辑  收藏  举报