2011-01-13 106 views
6

我試圖找出哪些是由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. 

回答

8

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

0

見下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