Visual Studio使用什么命令行参数来运行MsTest?

问题描述:

我试图找出哪些是由Visual Studio使用时运行MSTest的测试命令行参数,我想它的开头为:Visual Studio使用什么命令行参数来运行MsTest?

MSTest.exe /testmetadata:%SolutionName%.vsmdi /testlist: 

但我无法弄清楚如何填补testlist参数,因为无论是测试列表名称和ID出现以下错误:

The test list path 8c43105b-9dc1-4917-a39f-aa66a61bf5b6 cannot be found. 
An error occurred while executing the /testlist switch. 

I'm trying to figure out which is the command line arguments used by Visual Studio when you run the MsTest tests

这要看你怎么跑从Visual Studio的测试。请参见下面的例子:

  1. 您从Test View窗口中选择一些测试和运行它们

    MSTest.exe /testcontainer:TestProject.dll /test:TestMethod1 /test:TestMethod2 ... 
    
  2. 你从Test View窗口

    MSTest.exe /testcontainer:TestProject.dll 
    
  3. 运行所有测试您已经通过Test View窗口筛选了一个类别的测试,并运行此类别

    MSTest.exe /testcontainer:TestProject.dll /category:CategoryName 
    
  4. 你已经打开了*.vsmdi文件,并选择一些TestLists运行

    MSTest.exe /testmetadata:*.vsmdi /testlist:TestList1 /testlist:TestList2 ... 
    
  5. 您正在运行负载或有序测试

    MSTest.exe /testcontainer:LoadTest1.loadtest /testcontainer:OrderedTest1.orderedtest 
    

您可以在上面结合例子(参数)创建MSTest命令th适合你的情况。您唯一的限制是您不能一起使用/testmetada/testcontainer参数。

至于TestList参数,你只需要给参数列表的名称。如果找不到,那么您的测试列表不存在,或者它不属于您在/testmetadata参数中定义的*.vsmdi

我相信你已经做了,但你可以查看以下链接: MSTest.exe Command-Line Options

见下link。尽管这篇文章是关于msbuild的。它使用exec任务来调用mstest。 如果您使用/ testlist,您需要提供元数据文件。 您可以使用/ testcontainer并为您的测试项目提供dll。它会运行你所有的测试。

/testcontainer:[file name]  Load a file that contains tests. You can 
           Specify this option more than once to 
           load multiple test files. 
           Examples: 
           /testcontainer:mytestproject.dll 
           /testcontainer:loadtest1.loadtest