如何在批处理文件中从 Visual Studio 调用 Nunit
我已将 Visual Studio 设置为将 Nunit 作为外部程序启动,以运行模块中编写的所有测试。
现在我想做的是创建一个批处理文件,该文件将调用 Myproj.exe。 我期望它会运行 Nunit,因为我已将其设置为运行外部程序并执行 nunit.exe 中的所有测试,但是当我运行该批处理文件时,它开始从 Visual Studio 运行,而不是打开 NUnit。
任何人都可以给我一个关于如何实现它的清晰想法吗?
我太卡了。
现在我尝试在 shell
nunit-x86.exe 中运行以下命令 您能否告诉我应该如何在此处加载我的 VisualBasic 项目文件(exe),然后从此处运行所有测试 因为无法执行以下命令
nunit nunit.tests.vbproj /config:release
I have set my Visual Studio to start Nunit as an external program to run all the tests written in a module.
Now what I am trying to do is to create a batch file which will call Myproj.exe. What I am expecting is that it will run Nunit as I have set it to run an external program and execute all my tests in nunit.exe, but when I run that batch file it starts running from Visual Studio instead of opening NUnit.
Can any one please give me a clear idea as how to accomplish it?
I am too much stuck.
Now I am trying to run the following commands in shell
nunit-x86.exe
Can you please tell how should I load my visualbasic project file (exe) here and then run all the tests from here
as unable to execute following command
nunit nunit.tests.vbproj /config:release
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在每次调试“NUnit 测试”时启动 NUnit。
您可以在 Visual Studio Express 中附加调试器, 这样做。
如果您使用 VS 的“完整版本”,请这样做:
我从本教程(第4/5页)中得到了这些想法爱它。
You can make NUnit start everytime you debug your "NUnit tests".
You can attach the debugger in Visual Studio Express doing it that way.
If you use a "full version" of VS do it that way:
I got that ideas from this tutorial(Page 4/5) and love it.
您还可以在 Visual Studio 中每次成功构建后使用构建后事件运行 NUnit。
在 VS2005 中,右键单击包含测试的项目并选择“属性”。 然后在“构建事件”选项卡上的“构建后事件命令行”中,输入*以使用控制台:
或输入此以使用 GUI::
在“运行构建后事件:”中,保留默认值:“成功构建”
如果您使用 GUI,请注意您的构建将显示为挂起,直到您关闭 GUI 应用程序。
*注意:nunit 控制台 命令行文档 说“By默认情况下,nunit-console 程序不会添加到您的路径中。”
You can also run NUnit after every successful build in Visual Studio with a Post-Build Event.
In VS2005, right-click on the project that has your tests and select Properties. Then on the Build Events tab, in the "Post-build event command line", put this* to use the console:
or this to use the GUI::
In "Run the post-build event:", leave the default: "On successful build"
If you use the GUI, know that your build will appear to be hung up until you close the GUI app.
*NOTE: The nunit console command line docs say "By default the nunit-console program is not added to your path."
您只需使用命令行将 nunit.exe 添加到程序集中即可运行测试。
you can just shell nunit.exe with the command line to your assembly to run tests in.
您可以使用 Visual Studio 中的外部工具功能加载 nUnit.exe(用于命令行执行的 nUnit-Console.exe)。 通过外部工具功能添加命令后(如本博客中所述),您可以将它用于任何项目来执行测试。 (其他方法是通过项目属性添加,但这需要为每个项目完成)。 此外,在参数中,您可以传递 /include 或 /exclude 来包含或排除测试的类别。
此方法的优点是您无需担心提供 DLL 文件的路径,它适用于您所在的任何项目,并且只需单击几下即可执行
You can load nUnit.exe (nUnit-Console.exe for command line execution) using external tool features in Visual studio. Once you add the command via external tools feature (as explained in this blog), you can use it for any project to execute the tests. (Other is to add through project properties but that needs to be done for every project). Also in the arguments you can pass /include or /exclude to include or exclude categories of the tests.
The advantage of this method is you need not worry about giving path to DLL file and it works for any project you are on and gets executed with few clicks