I have set my Visual Studio to start Nunit as an external program to run all the tests written in a module.
我已经将我的Visual Studio设置为启动Nunit作为外部程序来运行模块中编写的所有测试。
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.
现在我要做的是创建一个将调用Myproj.exe的批处理文件。我期待的是它将运行Nunit,因为我已将其设置为运行外部程序并在nunit.exe中执行所有测试,但是当我运行该批处理文件时,它开始从Visual Studio运行而不是打开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
现在我试图在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-x86.exe你能告诉我该如何在这里加载我的visualbasic项目文件(exe),然后从这里运行所有测试,因为无法执行以下命令
nunit nunit.tests.vbproj /config:release
4 个解决方案
#1
You can make NUnit start everytime you debug your "NUnit tests".
每次调试“NUnit测试”时都可以启动NUnit。
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:
您可以在Visual Studio Express中以这种方式附加调试器。如果您使用VS的“完整版”,请执行以下操作:
Note that if you’re using the full and not the express version of Visual Studio 2005, you can do this by opening up the project’s properties, and in the Debug tab select Start External Program: and navigate to the NUnit executable, and set YourCompanyname.YourProject.Test.dll as the Command Line Arguments.
请注意,如果您使用的是Visual Studio 2005的完整版本而不是Express版本,则可以通过打开项目的属性来执行此操作,然后在“调试”选项卡中选择“启动外部程序:”并导航到NUnit可执行文件,并设置YourCompanyname .YourProject.Test.dll作为命令行参数。
I got that ideas from this tutorial(Page 4/5) and love it.
我从本教程(第4/5页)中得到了这些想法并喜欢它。
#2
You can also run NUnit after every successful build in Visual Studio with a Post-Build Event.
您还可以在使用Post-Build事件在Visual Studio中成功构建之后运行NUnit。
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:
在VS2005中,右键单击包含测试的项目,然后选择“属性”。然后在Build Events选项卡的“Post-build event命令行”中,将此*设置为使用控制台:
nunit-console /xml:$(ProjectName).xml $(TargetPath)
or this to use the GUI::
或者这个使用GUI ::
nunit $(TargetPath) /run
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.
如果您使用GUI,请知道在关闭GUI应用程序之前,您的构建似乎已挂起。
*NOTE: The nunit console command line docs say "By default the nunit-console program is not added to your path."
*注意:nunit控制台命令行文档说“默认情况下,nunit-console程序不会添加到您的路径中。”
#3
you can just shell nunit.exe with the command line to your assembly to run tests in.
你可以使用命令行将nunit.exe shell安装到程序集中以运行测试。
#4
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.
您可以使用Visual Studio中的外部工具功能加载nUnit.exe(nUnit-Console.exe以执行命令行)。通过外部工具功能添加命令后(如本博客中所述),您可以将其用于任何项目来执行测试。 (其他是通过项目属性添加,但需要为每个项目完成)。同样在参数中,您可以传递/包含或/排除以包含或排除测试的类别。
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
这种方法的优点是您不必担心提供DLL文件的路径,它适用于您所在的任何项目,只需点击几下即可执行
#1
You can make NUnit start everytime you debug your "NUnit tests".
每次调试“NUnit测试”时都可以启动NUnit。
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:
您可以在Visual Studio Express中以这种方式附加调试器。如果您使用VS的“完整版”,请执行以下操作:
Note that if you’re using the full and not the express version of Visual Studio 2005, you can do this by opening up the project’s properties, and in the Debug tab select Start External Program: and navigate to the NUnit executable, and set YourCompanyname.YourProject.Test.dll as the Command Line Arguments.
请注意,如果您使用的是Visual Studio 2005的完整版本而不是Express版本,则可以通过打开项目的属性来执行此操作,然后在“调试”选项卡中选择“启动外部程序:”并导航到NUnit可执行文件,并设置YourCompanyname .YourProject.Test.dll作为命令行参数。
I got that ideas from this tutorial(Page 4/5) and love it.
我从本教程(第4/5页)中得到了这些想法并喜欢它。
#2
You can also run NUnit after every successful build in Visual Studio with a Post-Build Event.
您还可以在使用Post-Build事件在Visual Studio中成功构建之后运行NUnit。
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:
在VS2005中,右键单击包含测试的项目,然后选择“属性”。然后在Build Events选项卡的“Post-build event命令行”中,将此*设置为使用控制台:
nunit-console /xml:$(ProjectName).xml $(TargetPath)
or this to use the GUI::
或者这个使用GUI ::
nunit $(TargetPath) /run
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.
如果您使用GUI,请知道在关闭GUI应用程序之前,您的构建似乎已挂起。
*NOTE: The nunit console command line docs say "By default the nunit-console program is not added to your path."
*注意:nunit控制台命令行文档说“默认情况下,nunit-console程序不会添加到您的路径中。”
#3
you can just shell nunit.exe with the command line to your assembly to run tests in.
你可以使用命令行将nunit.exe shell安装到程序集中以运行测试。
#4
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.
您可以使用Visual Studio中的外部工具功能加载nUnit.exe(nUnit-Console.exe以执行命令行)。通过外部工具功能添加命令后(如本博客中所述),您可以将其用于任何项目来执行测试。 (其他是通过项目属性添加,但需要为每个项目完成)。同样在参数中,您可以传递/包含或/排除以包含或排除测试的类别。
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
这种方法的优点是您不必担心提供DLL文件的路径,它适用于您所在的任何项目,只需点击几下即可执行