从 NUnit 迁移到 Team System 企业库配置中出现错误
在 Visual Studio 中运行一些测试时,我从 NUnit 迁移到 Team System 时收到此错误:
测试方法 XXX.XXX.Data.Tests.Path.Method> 抛出异常: 系统.配置.配置异常: 节名称无效。 这部分 “数据配置”不存在于 请求的配置文件 'C:\Program Files\Microsoft Visual 工作室 9.0\Common7\IDE\vstesthost.exe.Config' 或文件 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config'。 确保 'enterpriseLibrary.configurationSections' 配置部分存在于其中之一 文件和该部分 “dataConfiguration”已定义..
- 我们假设它是企业 图书馆,需要什么
我的测试的“配置部分” 上班? - 人们通常在哪里找到 团队系统中的配置文件?
- 另外为什么应用程序仍然 工作和测试不?
I get this error from my migration of NUnit to Team System when running some of the tests in Visual Studio:
Test method
XXX.XXX.Data.Tests.Path.Method> threw exception:
System.Configuration.ConfigurationException:
Invalid section name. The section
'dataConfiguration' does not exist in
the requested configuration file
'C:\Program Files\Microsoft Visual
Studio
9.0\Common7\IDE\vstesthost.exe.Config' or the file
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config'.
Make sure that the
'enterpriseLibrary.configurationSections'
configuration section exists in one of
the files and that the section
'dataConfiguration' is defined..
- We are assuming it is the enterprise
library, what is needed in the
"configuration section" for my tests
to work? - Where does one usually find the
configuration file in team system? - Also why is the application still
working and the tests not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来好像找不到 app.config/web.config 文件。
对于 MSTest,它不会在通常的“输出”目录中进行测试。 因此,“复制到输出目录”(等)标志什么也不做。 您需要告诉它哪些文件要部署到测试文件夹; 有两种方法:
[DeploymentItem]
属性添加到您的测试中,告诉它需要哪些文件我不太喜欢这两种方法 - 事实上,我倾向于使用TestDriven.NET 来运行测试,它按照您期望的方式运行。
当然,TestDriven.NET 也会在 IDE 中运行您的 NUnit 测试,包括代码覆盖率等 - 这就会引出一个问题:如果现有测试可以在 IDE 中运行,为什么要更改它们呢? 显而易见的答案是“我们已经为 MSTest 付费,而 TestDriven.NET 并不是免费的”...
It sounds like it can't find the app.config/web.config file.
With MSTest, it doesn't test in the usual "output" directory. As a consequence, the "copy to output directory" (etc) flags do nothing. You need to tell it which files to deploy to the test folder; there are two ways:
[DeploymentItem]
attribute to your test, telling it which files are neededI don't really like either approach - in fact, I tend to use TestDriven.NET to run the tests, which does it the way you expect it to behave.
Of course, TestDriven.NET would also run your NUnit tests in the IDE including code-coverage etc - which would then beg the question: why change your existing tests if they can work in the IDE? And the obvious answer is "we've paid for MSTest, and TestDriven.NET isn't free"...