Azure devops Visual Studio测试步骤成功完成后未报告代码覆盖率结果

Azure devops Visual Studio测试步骤成功完成后未报告代码覆盖率结果,azure-devops,code-coverage,Azure Devops,Code Coverage,我有一个非常简单的项目在我的VSTS帐户与一些测试。我在构建中添加了一个VsTest步骤,并选中了代码覆盖率框。但是,在我运行构建之后,它会说“没有可用的代码覆盖率结果”,并建议我向构建中添加VisualStudio测试构建步骤。但当我添加一个时,它与我已有的VsTest步骤相同 如何从我的VSTS构建中获得代码覆盖率 编辑:下面是测试日志。有两部分有很多特殊字符,我无法复制和粘贴 2018-05-04T21:51:59.5221025Z ##[section]Starting: VsT

我有一个非常简单的项目在我的VSTS帐户与一些测试。我在构建中添加了一个VsTest步骤,并选中了代码覆盖率框。但是,在我运行构建之后,它会说“没有可用的代码覆盖率结果”,并建议我向构建中添加VisualStudio测试构建步骤。但当我添加一个时,它与我已有的VsTest步骤相同

如何从我的VSTS构建中获得代码覆盖率

编辑:下面是测试日志。有两部分有很多特殊字符,我无法复制和粘贴

    2018-05-04T21:51:59.5221025Z ##[section]Starting: VsTest - testAssemblies
    2018-05-04T21:51:59.5227667Z ==============================================================================
    2018-05-04T21:51:59.5227804Z Task         : Visual Studio Test
    2018-05-04T21:51:59.5227968Z Description  : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test runner. Test frameworks that have a Visual Studio test adapter such as xUnit, NUnit, Chutzpah, etc. can also be run. Tests can be distributed on multiple agents using this task (version 2).
    2018-05-04T21:51:59.5228145Z Version      : 2.5.8
    2018-05-04T21:51:59.5228227Z Author       : Microsoft Corporation
    2018-05-04T21:51:59.5228339Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)
    2018-05-04T21:51:59.5228918Z ==============================================================================
    2018-05-04T21:52:00.6581473Z Run the tests locally using vstest.console.exe
    2018-05-04T21:52:00.6581612Z ========================================================
    2018-05-04T21:52:00.6582115Z Test selector : Test assemblies
    2018-05-04T21:52:00.6582269Z Test assemblies : **\release\**\*.dll
    2018-05-04T21:52:00.6582399Z Test filter criteria : null
    2018-05-04T21:52:00.6582534Z Search folder : D:\a\1\s
    2018-05-04T21:52:00.6582658Z Run settings file : D:\a\1\s
    2018-05-04T21:52:00.6582831Z Run in parallel : false
    2018-05-04T21:52:00.6582954Z Run in isolation : false
    2018-05-04T21:52:00.6584318Z Path to custom adapters : null
    2018-05-04T21:52:00.6584486Z Other console options : null
    2018-05-04T21:52:00.6584627Z Code coverage enabled : true
    2018-05-04T21:52:00.6584910Z Rerun failed tests: false
    2018-05-04T21:52:00.6585116Z VisualStudio version selected for test execution : latest
    2018-05-04T21:52:01.5193379Z ========================================================
    2018-05-04T21:52:01.5908190Z [command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @D:\a\_temp\60315131-4fe5-11e8-9269-e9217bdc2ba0.txt
    2018-05-04T21:52:06.6551385Z Microsoft (R) Test Execution Command Line Tool Version 15.6.2
    2018-05-04T21:52:06.6552014Z Copyright (c) Microsoft Corporation.  All rights reserved.
    2018-05-04T21:52:06.6552213Z 
    2018-05-04T21:52:06.8162937Z vstest.console.exe 
    2018-05-04T21:52:06.8164594Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\Microsoft.VisualStudio.CodeCoverage.Shim.dll"
    2018-05-04T21:52:06.8165659Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\TestTesting.dll"
    2018-05-04T21:52:06.8166614Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.abstractions.dll"
    2018-05-04T21:52:06.8167552Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.assert.dll"
    2018-05-04T21:52:06.8168335Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.core.dll"
    2018-05-04T21:52:06.8169121Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.execution.desktop.dll"
    2018-05-04T21:52:06.8169879Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.runner.reporters.net452.dll"
    2018-05-04T21:52:06.8170678Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.runner.utility.net452.dll"
    2018-05-04T21:52:06.8171460Z "D:\a\1\s\TestTesting\TestTesting\bin\Release\net461\xunit.runner.visualstudio.testadapter.dll"
    2018-05-04T21:52:06.8172221Z "D:\a\1\s\TestTesting\TestTesting\obj\Release\net461\TestTesting.dll"
    2018-05-04T21:52:06.8172936Z /EnableCodeCoverage
    2018-05-04T21:52:06.8173974Z /logger:"trx"
    2018-05-04T21:52:06.8174130Z /TestAdapterPath:"D:\a\1\s"
    2018-05-04T21:52:10.5221260Z Starting test execution, please wait...
    2018-05-04T21:52:10.9446034Z Test run will use DLL(s) built for framework .NETFramework,Version=v4.6.1 and platform X86. Following DLL(s) do not match framework/platform settings.
    2018-05-04T21:52:10.9446506Z xunit.assert.dll is built for Framework 1.1 and Platform AnyCPU.
    2018-05-04T21:52:10.9446876Z xunit.core.dll is built for Framework 1.1 and Platform AnyCPU.
    2018-05-04T21:52:10.9447201Z xunit.execution.desktop.dll is built for Framework 4.5.2 and Platform AnyCPU.
    2018-05-04T21:52:10.9449027Z xunit.runner.reporters.net452.dll is built for Framework 4.5.2 and Platform AnyCPU.
    2018-05-04T21:52:10.9449230Z xunit.runner.utility.net452.dll is built for Framework 4.5.2 and Platform AnyCPU.
    2018-05-04T21:52:10.9449440Z xunit.runner.visualstudio.testadapter.dll is built for Framework 4.5.2 and Platform AnyCPU.
    2018-05-04T21:52:10.9449631Z Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
    2018-05-04T21:52:10.9449774Z 

    [[Uncopyable part here. What I could read spelled out "Microsoft Coverage Collection", followed by a copyright.

    2018-05-04T21:52:31.9257584Z [xUnit.net 00:00:00.9144322]   Discovering: Microsoft.VisualStudio.CodeCoverage.Shim
    2018-05-04T21:52:32.0551765Z [xUnit.net 00:00:01.0599884]   Discovered:  Microsoft.VisualStudio.CodeCoverage.Shim
    2018-05-04T21:52:32.4727660Z [xUnit.net 00:00:01.4776210]   Discovering: TestTesting
    2018-05-04T21:52:32.7346755Z [xUnit.net 00:00:01.7395514]   Discovered:  TestTesting
    2018-05-04T21:52:32.7417690Z [xUnit.net 00:00:01.7468703]   Starting:    TestTesting
    2018-05-04T21:52:33.2084443Z [xUnit.net 00:00:01.9469140]     TestTesting.Tests.Skipped [SKIP]
    2018-05-04T21:52:33.2085046Z [xUnit.net 00:00:01.9471459]       Skipping
    2018-05-04T21:52:33.2085275Z [xUnit.net 00:00:01.9542762]   Finished:    TestTesting
    2018-05-04T21:52:33.2881381Z [xUnit.net 00:00:02.2931214]   Discovering: xunit.abstractions
    2018-05-04T21:52:33.3305957Z [xUnit.net 00:00:02.3357501]   Discovered:  xunit.abstractions
    2018-05-04T21:52:34.0395297Z [xUnit.net 00:00:03.0443103]   Discovering: xunit.runner.reporters.net452
    2018-05-04T21:52:34.1043673Z [xUnit.net 00:00:03.1090663]   Discovered:  xunit.runner.reporters.net452
    2018-05-04T21:52:34.4684448Z Passed   TestTesting.Tests.Passing
    2018-05-04T21:52:34.8614665Z Skipped  TestTesting.Tests.Skipped
    2018-05-04T21:52:34.8620656Z Standard Output Messages:
    2018-05-04T21:52:34.8620971Z  Skipping
    2018-05-04T21:52:34.8625877Z Passed   TestTesting.Tests.NoLongerFailing
    2018-05-04T21:52:36.1389527Z [xUnit.net 00:00:05.1437439]   Discovering: xunit.runner.utility.net452
    2018-05-04T21:52:36.2616608Z [xUnit.net 00:00:05.2660797]   Discovered:  xunit.runner.utility.net452

    [[Uncopyable part repeated here.]]

    2018-05-04T21:52:38.5800594Z Attachments:
    2018-05-04T21:52:38.5800836Z   D:\a\1\s\TestResults\b0d720b3-9bb9-4318-bb6b-7bfa8e404a13\VssAdministrator_factoryvm-az384 2018-05-04 21_52_18.coverage
    2018-05-04T21:52:38.5801023Z 
    2018-05-04T21:52:38.5801196Z Total tests: 3. Passed: 2. Failed: 0. Skipped: 1.
    2018-05-04T21:52:38.5801368Z Test Run Successful.
    2018-05-04T21:52:38.5809597Z Test execution time: 19.0295 Seconds
    2018-05-04T21:52:38.6045339Z Results File: D:\a\1\s\TestResults\VssAdministrator_factoryvm-az384_2018-05-04_21_52_34.trx
    2018-05-04T21:52:38.9702367Z ##[section]Async Command Start: Publish test results
    2018-05-04T21:52:39.1587014Z Publishing test results to test run '3'
    2018-05-04T21:52:39.1587207Z Test results remaining: 3. Test run id: 3
    2018-05-04T21:52:39.6699238Z Published Test Run : https://wjtesttesting.visualstudio.com/MyFirstProject/_TestManagement/Runs#runId=3&_a=runCharts
    2018-05-04T21:52:39.6700510Z ##[section]Async Command End: Publish test results
    2018-05-04T21:52:39.6701395Z ##[section]Finishing: VsTest - testAssemblies

[编辑2]:Starian Chen要求使用System.Debug设置为true的日志。它们超过了SO的尺寸限制,因此我在下面链接到它们:

编辑3:当我在VsTest构建步骤的“其他控制台选项”中指定框架时:

/framework:"Framework461"
它似乎对我的版本不满意。它给出了受支持框架的列表,其中最高的是“Framework45”


编辑4:我尝试了一个带有“Framework45”的net452项目。在这种情况下,测试确实是按照Starian Chen的指示运行的,只是将“Framework45”替换为“netcoreapp2.0”。但是,仍然没有代码覆盖率报告。

对于.Net framework测试项目,您不需要在Visual Studio测试任务中指定framework和vstest.console.exe路径

对于.Net framework测试项目,您不需要在Visual Studio测试任务中指定framework和vstest.console.exe路径

您使用的是什么测试框架?你看到公布的测试结果了吗?Visual Studio测试任务的输出是什么?xunit。它在解决方案中运行良好。两次通过和一次跳过的测试。你说“它在解决方案中运行良好”是什么意思?它在VisualStudio测试步骤中工作正常吗?请使用该步骤的日志更新您的问题。已添加。我的意思是,它在我的本地版本中运行良好。你能用一个新项目重现这个问题吗?如果是这样,您可以在OneDrive上共享示例项目。另一方面,对于.net framework测试项目,您不需要在VS test Task中指定framework和vstest.console.exe路径您使用的是什么测试框架?你看到公布的测试结果了吗?Visual Studio测试任务的输出是什么?xunit。它在解决方案中运行良好。两次通过和一次跳过的测试。你说“它在解决方案中运行良好”是什么意思?它在VisualStudio测试步骤中工作正常吗?请使用该步骤的日志更新您的问题。已添加。我的意思是,它在我的本地版本中运行良好。你能用一个新项目重现这个问题吗?如果是这样,您可以在OneDrive上共享示例项目。另一方面,对于.net framework测试项目,您不需要在VS测试任务中指定framework和vstest.console.exe路径