2017-03-02 79 views
-1

我有一個調用mstest的構建工作流程(xaml)。我的期望是會有一個鏈接到構建摘要頁面上的測試結果。然而,這種情況並非如此。如何從TFS構建頁面提供mstest結果?

構建以MSTest命令結束 - 由於出現故障而退出1。所以,MSTest是工作流程中的最後一項活動。

這裏肯定有些問題。放置位置僅包含工作流程日誌 - 沒有測試結果。這些可在TestResults文件夾中找到,但不在放置位置。

所以,我的問題是 - 我該如何連線MSTest活動,以便在最後會有一個鏈接到測試結果的某處?


現在的血淋淋的細節。這就是工作流程最後時刻在活動日誌中的樣子(爲簡潔起見,我用替換了一些東西)。最後注意以下消息:

Publishing results of test run [email protected] 2017-03-02 16:03:43_Any CPU_Release to http://tfsserver:8080/tfs/defaultcollection... 
     ................Publish completed successfully. 

但是它在哪裏發佈?

MSTest 
    Inputs 
     TestLists: 
     ToolPath: 
     TestNames: 
     MinPriority: -1 
     TestSettings: 
     CommandLineArguments: 
     SearchPathRoot: d:\b\test\3269\..\2282\Binaries 
     Platform: Any CPU 
     MaxPriority: -1 
     Category: 
     RunTitle: 
     PathToResultsFilesRoot: d:\b\test\3269\..\2282\TestResults 
     TestContainers: System.Linq.Enumerable+WhereEnumerableIterator`1[System.String] 
     TestMetadata: 
     TestConfigName: 
     Flavor: Release 
     TestConfigId: -1 
     Publish: True 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe /nologo /usestderr /searchpathroot:"d:\b\test\3269\..\2282\Binaries" /resultsfileroot:"d:\b\test\3269\..\2282\TestResults" /testcontainer:"d:\b\test\2282\Binaries\BackgroundJobTests.dll" [...] /publish:"http://tfsserver:8080/tfs/defaultcollection" /noprompt /publishbuild:"vstfs:///Build/Build/265747" /teamproject:"DFDev" /platform:"Any CPU" /flavor:"Release" 
    Loading d:\b\test\2282\Binaries\BackgroundJobTests.dll... 
    [...] 
    Starting execution... 
    Warning: The disabled test 'GetJobReqModels' was removed from the test run. 

    Results Top Level Tests 
    ------- --------------- 
    Passed BackgroundJobTests.AsyncParallelSqlRunnerTest.AsyncExceptionInDoIt 
    [...] 
    Passed WFMCommonTest.TimesheetApi.UnitTests.TimeSegmentApiTests.Test_RoundTimeOfOneSegment 
    1778/5035 test(s) Passed, 3224 Failed, 33 Error 

    Summary 
    ------- 
    Passed 1778 
    Failed 3224 
    Error 33 
    ------------ 
    Total 5035 
    Results file: d:\b\test\2282\TestResults\tfsbuild_TORSVARCH01 2017-03-02 16_03_43_Any CPU_Release.trx 
    Test Settings: Default Test Settings 
    Test Run Error. 

    Run has the following issue(s): 
    Warning: Test Run deployment issue: The assembly or module 'dtSearchNetApi2' directly or indirectly referenced by the test container 'd:\b\test\2282\binaries\ruleenginetests.dll' was not found. 
    [...] 
    Warning: Test Run deployment issue: The assembly or module 'System.ServiceModel.Web' directly or indirectly referenced by the test container 'd:\b\test\2282\binaries\utilitytest.dll' was not found. 
    One of the background threads threw exception: 
    System.Data.OleDb.OleDbException (0x80004005): Cannot open database "851qa89" requested by the login. The login failed. 
    [...] 
    One of the background threads threw exception: 
    System.InvalidOperationException: Collection was modified; enumeration operation may not execute. 
    [...] 
    Waiting to publish... 
    Publishing results of test run [email protected] 2017-03-02 16:03:43_Any CPU_Release to http://tfsserver:8080/tfs/defaultcollection... 
    ................Publish completed successfully. 
    Exception Message: MSTest.exe returned an exit code of 1 indicating that not all tests passed. (type TestFailureException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities 

編輯1

我們使用TFS 2015年構建模板是一個自定義的。

的MSTEST命令行參數可從前述的樣品中觀察到,但在這裏它們被再次破碎爲方便起見,每行一個:

/nologo 
/usestderr 
/searchpathroot:"d:\b\test\3269\..\2282\Binaries" 
/resultsfileroot:"d:\b\test\3269\..\2282\TestResults" 
/testcontainer:"d:\b\test\2282\Binaries\BackgroundJobTests.dll" ... 
/publish:"http://tfsserver:8080/tfs/defaultcollection" 
/noprompt 
/publishbuild:"vstfs:///Build/Build/265747" 
/teamproject:"DFDev" 
/platform:"Any CPU" 
/flavor:"Release" 

d:\b\test\2282\TestResults夾確實包含TRX文件和輔助目錄。但這還不夠好 - 我想看起來他們在線。 mstest聲稱它們已發佈:

Publishing results of test run [email protected] 2017-03-02 16:03:43_Any CPU_Release to http://tfsserver:8080/tfs/defaultcollection... 
     ................Publish completed successfully. 

但是什麼是地址?

EDIT 2

我檢查構建的在線摘要頁面和檢測結果的鏈接是存在的,但它不是一個可以在Visual Studio中查看摘要頁面上找到。

請遵守頁面,我可以在Visual Studio 2015年看到: enter image description here

現在,當通過瀏覽器訪問同一頁面。注意超鏈接到頁面右側的測試: enter image description here

所以,我想我的問題可以縮小到如何能夠在Visual Studio中的生成摘要頁面上看到這個鏈接?

編輯3

這裏是我的幾乎整個構建流程 - http://pastebin.com/9z2UE79E

爲了節省一些空間,我刪除了兩個部分:

  1. 的InvokeProcess活動升級數據庫
  2. InvokeProcess活動修改某個配置文件。

我不明白我需要做什麼才能在總結頁面中包含測試摘要。

+0

您正在使用哪個版本的TFS?你是如何定製構建過程模板的? –

+0

給匿名downvoter - 謹慎提供理由? – mark

回答

0

您似乎在MSTest活動中使用/publish選項。使用/publish選項將測試數據發佈到與項目的Team Foundation Server關聯的團隊項目集合的數據庫。

檢查:https://msdn.microsoft.com/en-us/library/ms243151(v=vs.120).aspx

+0

請參閱我的**編輯2 **。謝謝。 – mark

+0

對於TFS 2015中的默認XAML構建,VS中的構建摘要頁面上有測試結果。但從您的屏幕截圖中,您的構建摘要頁面也是自定義的,恐怕您需要進一步的自定義才能添加測試結果部分,內容如下:https://blogs.msdn.microsoft.com/buckh/2012/06/07/如何對定製最集結匯總頁面中-TFS-2012-沒有-A-插件/。 –

+0

由於您使用的是TFS 2015,因此建議從XAML構建遷移到基於新任務的構建系統。使用新的構建系統,您不需要進行自定義,只需添加VS Test任務即可調用自定義測試適配器:https://github.com/Microsoft/vsts-tasks/blob/releases/m109/Tasks/VsTest/ README.md –