如何从命令行运行单元测试测试? [英] How to run unit testing tests from command line?

查看:603
本文介绍了如何从命令行运行单元测试测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我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:


  1. 一个特定的测试

  2. 类中的所有测试

  3. 当前TFS暂挂更改的所有影响测试

  4. 所有测试

  5. 除了标记为类别[TestCategory(some-category)]的测试之外的所有测试]

  1. A specific test (ie. a test written by a method marked [TestMethod()])
  2. All tests in a class
  3. All impacted tests of the current TFS pending change of mine.
  4. All tests
  5. 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!

参考资料:


  1. MSTest .exe http://msdn.microsoft.com/en-us/library/ms182487.aspx

  2. MSTest.exe的详细选项 http:// msdn。 microsoft.com/en-us/library/ms182489.aspx

  3. 获取结果 http://msdn.microsoft.com/en-us/library/ms182488.aspx

  1. the MSTest.exe http://msdn.microsoft.com/en-us/library/ms182487.aspx
  2. the MSTest.exe's detailed options http://msdn.microsoft.com/en-us/library/ms182489.aspx
  3. obtaining the result http://msdn.microsoft.com/en-us/library/ms182488.aspx





过了一段时间后,我发现了以下有用的提示。

After a while, I found the below useful tips.


  1. 使用位于%ProgramFiles%\ Microsoft Visual Studio 10.0 \Common7\IDE\MSTest.exe 的MSTest.exe运行Visual Studio单元测试。在我的情况下。

  2. 使用 /testcontainer:Path\To\Your\TestProjectAssembly.dll 编码。您可以根据需要指定多个'/ testcontainer'选项。

  3. 使用 / test:TestFilter 过滤要运行的测试。请注意,此过滤器应用于完整的测试方法名称(即FullNamespace.Classname.MethodName)

  1. run Visual Studio unit tests by using MSTest.exe, located at %ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe in my case.
  2. using /testcontainer:Path\To\Your\TestProjectAssembly.dll to indicate where your tests are coded. You can specify multiple '/testcontainer' options if required.
  3. 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:


  1. 特定测试(即由标记为 [TestMethod()] br>
    使用 MSTest.exe / container: TheAssemblyContainingYourSpecificTest $ c> / test:

  1. A specific test (ie. a test written by a method marked [TestMethod()])
    Use MSTest.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆