如何从命令行运行单元测试测试? [英] How to run unit testing tests from command line?
问题描述
我googled,并找到以下有用的参考。目前我想在命令行中运行所有命令行(为了方便执行和快速):
I googled and found the below helpful references. Currently I want to run all from the command-line (for easy of execution & quickness) in cases:
- 一个特定的测试
- 类中的所有测试
- 当前TFS暂挂更改的所有影响测试
- 所有测试
- 除了标记为类别[TestCategory(some-category)]的测试之外的所有测试]
- A specific test (ie. a test written by a method marked [TestMethod()])
- All tests in a class
- All impacted tests of the current TFS pending change of mine.
- All tests
- All tests except the ones marked as category [TestCategory("some-category")]
我不知道如何为我的需要写一个正确的命令。
I'm not sure how can I write a correct command for my needs above.
如果你知道,请分享!
If you know know, please share! All helps are welcomed and very much appriciated!
参考资料:
- MSTest .exe http://msdn.microsoft.com/en-us/library/ms182487.aspx
- MSTest.exe的详细选项 http:// msdn。 microsoft.com/en-us/library/ms182489.aspx
- 获取结果 http://msdn.microsoft.com/en-us/library/ms182488.aspx
- the MSTest.exe http://msdn.microsoft.com/en-us/library/ms182487.aspx
- the MSTest.exe's detailed options http://msdn.microsoft.com/en-us/library/ms182489.aspx
- obtaining the result http://msdn.microsoft.com/en-us/library/ms182488.aspx
过了一段时间后,我发现了以下有用的提示。
After a while, I found the below useful tips.
- 使用位于
%ProgramFiles%\ Microsoft Visual Studio 10.0 \Common7\IDE\MSTest.exe
的MSTest.exe运行Visual Studio单元测试。在我的情况下。 - 使用
/testcontainer:Path\To\Your\TestProjectAssembly.dll
编码。您可以根据需要指定多个'/ testcontainer'选项。 - 使用
/ test:TestFilter
过滤要运行的测试。请注意,此过滤器应用于完整的测试方法名称(即FullNamespace.Classname.MethodName)
- run Visual Studio unit tests by using MSTest.exe, located at
%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe
in my case. - using
/testcontainer:Path\To\Your\TestProjectAssembly.dll
to indicate where your tests are coded. You can specify multiple '/testcontainer' options if required. - using
/test:TestFilter
to filter the tests to run. Note that this filter is applied to the full test method name (ie. FullNamespace.Classname.MethodName)
希望这可以帮助你们。
Hope this helps you guys.
推荐答案
目前我可以为我的需要提供一些答案:
Currently I can have some answers for my needs:
-
特定测试(即由标记为
[TestMethod()]
br>
使用MSTest.exe
/ container:
TheAssemblyContainingYourSpecificTest $ c> / test:
A specific test (ie. a test written by a method marked
[TestMethod()]
)
UseMSTest.exe
/container:
TheAssemblyContainingYourSpecificTest/test:
TheSpecificTestName
>
使用 MSTest.exe
/ container:
TheAssemblyContainingYourClass / test:
TheClassNameWithFullNamespace
请注意, / test:
在过滤时使用类的全名的过滤器。
All tests in a class
Use MSTest.exe
/container:
TheAssemblyContainingYourClass /test:
TheClassNameWithFullNamespace
Note that the /test:
is the filter which uses the full name of the class when filtering.
其他的仍然未知。如果你知道如何,请讨论。
The others are still left unknown. Please disscuss if you know how.
这篇关于如何从命令行运行单元测试测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!