nunit 测试中数据文件的路径名
至少在 MonoDevelop 中,我发现 nunit 测试使用 bin 目录的 CurrentDirectory 启动。没有明显的运行选项可以改变这一点。
是否有一些 nunit-y 好的方法来定位数据文件,或者我应该在运行配置中设置一个环境变量?
In MonoDevelop, at least, I find that nunit tests launch with a CurrentDirectory of the bin directory. There's no apparent run option to change that.
Is there some nunit-y nice way to locate data files, or should I just set an environment variable in the run configuration?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有直接回答您的问题,但之前已经遇到过这个问题好几次了;通常使用以下一个或多个选项的组合:
将外部资源文件夹放入配置文件中并在测试开始时加载它们。这里描述了一种很好的技术:配置文件和 NUnit测试
将我的测试资源\数据文件进行卷影复制。如果您将资源保存在解决方案树中,VS 宏可以使此任务变得非常容易。
将我的测试资源编译成一个程序集或一组程序集,并在单元测试中引用它。这里有一篇关于此主题的博客文章:使用外部文件进行测试
希望这会有所帮助
Don't have a direct answer to your question but was through this problem quite a few times before; usually using one or a combination of options below:
put external resources folders into the configuration file and load them on the test start. There is a nice technique for doing this described here: Config files and NUnit tests
shadow copy my test resource\data files after successful build into the unit test's bin folder. VS macro can make this task quite easy if you hold your resources within the solution tree.
have my test resources compiled into an assembly or a set of assemblies and reference it in the unit test. There is a blog post on this topic here: Testing with external files
hope this helps