NUnit not looking the file in the right folder

送分小仙女□ 提交于 2019-12-11 13:38:54

问题


I just updated nUnit from 2.6.4 to 3.0.1 on my VS2015. Everything went well with just ONE problem.

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.

But, with Nunit 3.0.1, I receive this error:

System.IO.FileNotFoundException : Could not find file 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\UnitTestConfiguration.xml'.

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?


回答1:


Yes, this is a Breaking Change in NUnit3, tests are no longer ran in the root folder.

Use TestContext.TestDirectory to reach it.



来源:https://stackoverflow.com/questions/35494833/nunit-not-looking-the-file-in-the-right-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!