NUnit 没有在正确的文件夹中查找文件 [英] NUnit not looking the file in the right folder
问题描述
我刚刚在 VS2015 上将 nUnit 从 2.6.4 更新到 3.0.1.一切都很顺利,只有一个问题.
I just updated nUnit from 2.6.4 to 3.0.1 on my VS2015. Everything went well with just ONE problem.
在我的 Test
方法中,我必须加载一个 xml 文件,我们称之为 UnitTestConfiguration.xml
,它与 保存在同一个根文件夹中app.Config
和 package.Config
文件.在 NUnit 2.6.4 中,这个 xml 文件被找到并完美加载.
In my Test
method, I have to load a xml file, let's call it UnitTestConfiguration.xml
, it is saved inside the same root folder as the app.Config
and package.Config
file. With NUnit 2.6.4, this xml file is being found and load perfectly.
但是,使用 Nunit 3.0.1,我收到此错误:
But, with Nunit 3.0.1, I receive this error:
System.IO.FileNotFoundException : 找不到文件C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\UnitTestConfiguration.xml".
System.IO.FileNotFoundException : Could not find file 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\UnitTestConfiguration.xml'.
所以我的问题是,为什么 3.0.1 一开始不查看测试项目的根文件夹,而是查看其他地方?是否有任何设置可以纠正它?
So my question is, why would 3.0.1 not look into the root folder of the test project to begin with, but somewhere else? Is there any setting(s) to correct it?
推荐答案
是的,这是一个 在 NUnit3 中的重大更改,不再在根文件夹中运行测试.
Yes, this is a Breaking Change in NUnit3, tests are no longer ran in the root folder.
使用 TestContext.TestDirectory
来访问它.
这篇关于NUnit 没有在正确的文件夹中查找文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!