nUnit Test 函数使用可执行路径打开文件
我有一个打开应用程序帮助文件的功能。该函数有 3 个参数:
显示帮助(appPath, 1, @“heelp\help.doc”)
- 第一个参数是起始路径。
- 第二个参数是 升级起始路径。
- 第三个参数是帮助文件的路径 从上往上n层后 起始路径。
为了测试这一点,我在测试项目中创建了一个 Resources 文件夹,在该文件夹中添加了一个文档并提供了以下内容:
controller.ShowHelp(Application.ExecutablePath, 1、@"Resources\h.doc");
但是,当我通过 testdriven.net 运行此命令时,我的可执行路径返回为:
“C:\Program Files\TestDriven.NET 2.0\进程调用.exe"
- 如何在测试中提供我的测试项目的路径?
- 有没有更简单的方法来测试此方法?
谢谢!
I have a function which opens up the help file for the app. The function takes 3 arguments :
ShowHelp(appPath, 1,
@"heelp\help.doc")
- The first argument is the start path.
- The second argument is the no of
levels up the start path. - The third argument is the path of the help file
after going up n levels from the
start path.
To test this I created a Resources folder in my test project, added a doc into this folder and supplied the below:
controller.ShowHelp(Application.ExecutablePath,
1, @"Resources\h.doc");
However when I run this thru test driven.net , my executable path is coming back as :
"C:\Program Files\TestDriven.NET
2.0\ProcessInvocation.exe"
- How do I supply the path of my Test Project in the test?
- Is there any easier way to test this method?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果使用,
您应该获取包含测试的库的路径,可能类似于 (..\bin\Debug),然后您可以调整其他参数。
If you use
you should obtain the path for the library containing the tests, probably something like (..\bin\Debug), and then you can adapt the other parameters.
你应该使你的路径相对。
http:// /blogs.lessthandot.com/index.php/DesktopDev/MSTech/application-startuppath-and-nunit?highlight=application.startuppath&sentence=
换句话说,将 application.executablepath 替换为“/”。请参阅博客了解更多详细信息。
you should make your path relative.
http://blogs.lessthandot.com/index.php/DesktopDev/MSTech/application-startuppath-and-nunit?highlight=application.startuppath&sentence=
in other words replace the application.executablepath with "/". See blog for more detail.