搜索 nunit 单元测试的文件依赖项
我有一个 winforms C# 类,它在内部查找文件。为了帮助单元测试,我将其更改为从外部传递文件,例如:
string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + " TestXML.xml");
Foo = new Foo(文件);
问题是代码正常工作正常,但在 Nunit 中运行时会出现错误,提示“无法找到目录 C:\doc & settings\ . . .. testxml.xml
有什么想法吗?
I had a winforms C# class that internally was looking up a file.. to help unit test, i changed it to pass in a file from the outside such as:
string file = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "TestXML.xml");
Foo = new Foo(file);
the problem is that the code works fine normally but when run in Nunit it comes us with an error saying "Cant find directory C:\doc & settings\ . . .. testxml.xml
any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会设置一个断点,然后使用立即窗口来找出传递给 GetDirectoryName 的内容。 这可能不是你想要的。
I would set a breakpoint and then use the immediate window to find out what is getting passed to GetDirectoryName. It probably isn't what you intended.