有没有人有解决方案在TFS构建摘要中包含Chutzpah代码覆盖率?单元测试运行正常,但我没有得到任何代码覆盖率。我们的项目有一个DOD,代码覆盖率为85%,所以在构建过程中自动化这个很好。
2016-01-12T07:58:08.5718428Z Executing the powershell script: D:\TFSAgent\tasks\VSTest\1.0.22\VSTest.ps1
2016-01-12T07:58:08.7749779Z ##[debug]Calling Invoke-VSTest for all test assemblies
2016-01-12T07:58:08.7905962Z Working folder: D:\TFSAgent\_work\6
2016-01-12T07:58:08.7905962Z Executing C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe "D:\TFSAgent\_work\6\s\src\FSP.Tests\sampletests.js" /Settings:"D:\TFSAgent\_work\6\s\buildtools\common.runsettings" /EnableCodeCoverage /logger:trx /TestAdapterPath:"D:\TFSAgent\_work\6\s\src\packages\Chutzpah.4.1.0\tools"
2016-01-12T07:58:08.9780981Z Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
2016-01-12T07:58:08.9780981Z Copyright (c) Microsoft Corporation. All rights reserved.
2016-01-12T07:58:09.2437191Z Starting test execution, please wait...
2016-01-12T07:58:09.3062199Z Warning: Using Isolation mode to run the tests as diagnostic data adapters were enabled in the runsettings. Use the /inIsolation parameter to suppress this warning.
2016-01-12T07:58:14.2165110Z Information: Log Message: waiting for blanket... from D:\TFSAgent\_work\6\s\src\FSP.Tests\sampletests.js
2016-01-12T07:58:20.7009092Z Passed SamleTest has a test
2016-01-12T07:58:20.7009092Z Passed app testController has a controller defined
2016-01-12T07:58:20.7009092Z Passed app testController echo returns same string
2016-01-12T07:58:20.7477777Z Results File: D:\TFSAgent\_work\6\TestResults\G04SEASLOID2$_G04SEASLOID2 2016-01-12 08_58_20.trx
2016-01-12T07:58:20.7477777Z Attachments:
2016-01-12T07:58:20.7477777Z D:\TFSAgent\_work\6\TestResults\5f30d7de-bf10-44c2-b9f3-0640da2b8183\G04SEASLOID2$_G04SEASLOID2 2016-01-12 08_58_11.coverage
2016-01-12T07:58:20.7477777Z Total tests: 3. Passed: 3. Failed: 0. Skipped: 0.
2016-01-12T07:58:20.7477777Z Test Run Successful.
2016-01-12T07:58:20.7633997Z Test execution time: 8,2573 Seconds
2016-01-12T07:58:20.8883985Z Publishing Test Results...
2016-01-12T07:58:21.5290256Z Test results remaining: 3
2016-01-12T07:58:21.8415328Z Published Test Run : http://g04seasloid2:8181/tfs/DefaultCollection/FS%20Portal%20Project/_TestManagement/Runs#runId=272&_a=runCharts
common.runsettings文件如下所示
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>..\..\TestResults</ResultsDirectory>
<TargetPlatform>x86</TargetPlatform>
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
</RunConfiguration>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Include>
</Include>
<Exclude>
<ModulePath>.*\.tests\..*</ModulePath>
<ModulePath>.*TestAdapter.*</ModulePath>
<ModulePath>.*packages.*</ModulePath>
</Exclude>
</ModulePaths>
<Functions>
<Exclude>
<Function>^Fabrikam\.UnitTest\..*</Function>
<Function>^std::.*</Function>
<Function>^ATL::.*</Function>
<Function>.*::__GetTestMethodInfo.*</Function>
<Function>^Microsoft::VisualStudio::CppCodeCoverageFramework::.*</Function>
<Function>^Microsoft::VisualStudio::CppUnitTestFramework::.*</Function>
</Exclude>
</Functions>
<Attributes>
<Exclude>
<Attribute>^System.Diagnostics.DebuggerHiddenAttribute$</Attribute>
<Attribute>^System.Diagnostics.DebuggerNonUserCodeAttribute$</Attribute>
<Attribute>^System.Runtime.CompilerServices.CompilerGeneratedAttribute$</Attribute>
<Attribute>^System.CodeDom.Compiler.GeneratedCodeAttribute$</Attribute>
<Attribute>^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$</Attribute>
<Attribute>^NUnit.Framework.TestFixtureAttribute$</Attribute>
<Attribute>^Xunit.FactAttribute$</Attribute>
<Attribute>^Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute$</Attribute>
</Exclude>
</Attributes>
<Sources>
<Exclude>
<Source>.*\\atlmfc\\.*</Source>
<Source>.*\\vctools\\.*</Source>
<Source>.*\\public\\sdk\\.*</Source>
<Source>.*\\microsoft sdks\\.*</Source>
<Source>.*\\vc\\include\\.*</Source>
</Exclude>
</Sources>
<CompanyNames>
<Exclude>
<CompanyName>.*microsoft.*</CompanyName>
</Exclude>
</CompanyNames>
<PublicKeyTokens>
<Exclude>
<PublicKeyToken>^B77A5C561934E089$</PublicKeyToken>
<PublicKeyToken>^B03F5F7F11D50A3A$</PublicKeyToken>
<PublicKeyToken>^31BF3856AD364E35$</PublicKeyToken>
<PublicKeyToken>^89845DCD8080CC91$</PublicKeyToken>
<PublicKeyToken>^71E9BCE111E9429C$</PublicKeyToken>
<PublicKeyToken>^8F50407C4E9E73B6$</PublicKeyToken>
<PublicKeyToken>^E361AF139669C375$</PublicKeyToken>
</Exclude>
</PublicKeyTokens>
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
<CollectFromChildProcesses>True</CollectFromChildProcesses>
<CollectAspDotNet>False</CollectAspDotNet>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
<MSTest>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>false</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>False</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
<ChutzpahAdapterSettings>
<TestingMode>All</TestingMode>
</ChutzpahAdapterSettings>
</RunSettings>
答案 0 :(得分:1)
VS中有built-in code coverage个功能。无论您使用的是XAML构建还是vNext构建,您只需在构建定义中启用相关设置。
对于XAML构建
以下是介绍Continuous Integration with JavaScript, NUnit on TFSBuild的博客,供您参考。
答案 1 :(得分:1)
这是一个老话题,但对于将来绊倒这个的其他人来说:
这假设你正在使用Karma和VSTS&#34; Build vNext&#34;管道
为了将代码覆盖作为构建的一部分,请将TrxReporter添加到您的Karma.config.js,如下所示
trxReporter: { outputFile: 'Javascrip-test-results.trx' shortTestName: false}
您现在可以配置构建任务以将Karma作为构建的一部分(即NPM任务)运行,之后您可以使用&#34;发布测试结果&#34;来获取trx输出。任务。
有关详细说明,请参阅http://www.clemensreijnen.nl/post/2016/10/17/CICD-Pipeline-for-Angular2-with-VSTS