2011-05-19 94 views
1

MSTest的參數,我想阻止某些(MSTest的)單元測試被我們構建服務器上運行。我真的很想只需添加一個TestCategory,然後指定:指定的MSBuild

/category:"!RequiresLoginCredentials" 

但我不知道如何表明,在MSBuild項目文件。

構建文件的有關部分目前有:

<ItemGroup> 
    <!-- TEST ARGUMENTS 
    If the RunTest property is set to true then the following test arguments will be used to run 
    tests. Tests can be run by specifying one or more test lists and/or one or more test containers. 

    To run tests using test lists, add MetaDataFile items and associated TestLists here. Paths can 
    be server paths or local paths, but server paths relative to the location of this file are highly 
    recommended: 

     <MetaDataFile Include="$(BuildProjectFolderPath)/HelloWorld/HelloWorld.vsmdi"> 
      <TestList>BVT1;BVT2</TestList> 
     </MetaDataFile> 

    To run tests using test containers, add TestContainer items here: 

     <TestContainer Include="$(OutDir)\HelloWorldTests.dll" /> 
     <TestContainer Include="$(SolutionRoot)\TestProject\WebTest1.webtest" /> 
     <TestContainer Include="$(SolutionRoot)\TestProject\LoadTest1.loadtest" /> 

    Use %2a instead of * and %3f instead of ? to prevent expansion before test assemblies are built 
    --> 
    <TestContainer Include="$(OutDir)\UnitTests.dll" /> 

    </ItemGroup> 

我猜這是一個簡單的加法,但我不是很瞭解的MSBuild。

謝謝!

+0

你用什麼版本構建服務器呢? – 2011-05-19 16:13:05

+0

我相信我們是對的MSBuild 4,與2008年TFS – 2011-05-19 16:15:47

+0

我沒有使用TFS,但並不是這樣的事情通常與TestManager的配置? – 2011-05-20 01:35:48

回答

5

我做了回答一個簡單的搜索,我認爲有兩個可能的解決方案:

  1. 從你所描述的,看起來像你試圖運行使用的MSBuild的TestToolTask task測試。不幸的是,我不認爲你可以直接將MSTest參數傳遞給這個任務。爲了完成你想要的任務,你需要指定你想在測試列表中運行的測試,並將測試列表傳遞給這個任務。您需要使用MetadataFile屬性,如帖子中的示例所示。

  2. 您可以直接使用的MSBuild的Exec task調用MSTest.exe。這樣你就可以自由地傳遞你想要的參數。

相關問題