如何从TFS构建页面提供mstest结果?

时间:2017-03-02 21:48:43

标签: tfs mstest

我有一个调用mstest的构建工作流程(xaml)。我的期望是,在构建摘要页面上可以找到测试结果的链接。但事实并非如此。

构建以MSTest命令结束 - 以1退出,因为存在失败。因此,MSTest是工作流程中的最后一项活动。

这里肯定是错的。放置位置仅包含工作流日志 - 没有测试结果。这些可以在TestResults文件夹中找到,但不能在放置位置找到。

所以,我的问题是 - 我如何连接MSTest活动,以便最终在测试结果的某处有一个链接?

现在有血腥的细节。这就是工作流程的最后时刻在活动日志中的样子(为了简洁起见,我用 [...] 替换了一些东西)。请注意最后的以下消息:

Publishing results of test run tfsbuild@TORSVARCH01 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 tfsbuild@TORSVARCH01 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 tfsbuild@TORSVARCH01 2017-03-02 16:03:43_Any CPU_Release to http://tfsserver:8080/tfs/defaultcollection...
        ................Publish completed successfully.

但是地址是什么?

编辑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活动。
  3. 我不明白如何在整个“摘要”页面中包含“测试摘要”。

1 个答案:

答案 0 :(得分:0)

您似乎在MSTest活动中使用 / publish 选项。使用 / publish 选项将测试数据发布到与项目的Team Foundation Server关联的团队项目集合的数据库中。

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