.net core VSTS生成:测试运行,但测试失败,报告为失败,并带有“0”;Vstest失败,出现错误。检查日志中的故障。可能会有失败的测试。”;

.net core VSTS生成:测试运行,但测试失败,报告为失败,并带有“0”;Vstest失败,出现错误。检查日志中的故障。可能会有失败的测试。”;,.net-core,azure-devops,mstest,azure-pipelines,.net Core,Azure Devops,Mstest,Azure Pipelines,我需要一些VSTS托管构建的帮助 在托管的VSTS生成上,运行测试任务运行测试,但随后被标记为失败,尽管测试实际正在运行 相关线路为: System.IO.FileNotFoundException:找不到的测试 D:\a\1\s\src\XXX.YYY.IntegrationTests\obj\Release\netcoreapp2.1\XXX.yy.IntegrationTests.dll。 确保测试项目具有包的nuget引用 “Microsoft.NET.Test.Sdk”和框架版本设置

我需要一些VSTS托管构建的帮助

在托管的VSTS生成上,运行测试任务运行测试,但随后被标记为失败,尽管测试实际正在运行

相关线路为:

System.IO.FileNotFoundException:找不到的测试 D:\a\1\s\src\XXX.YYY.IntegrationTests\obj\Release\netcoreapp2.1\XXX.yy.IntegrationTests.dll。 确保测试项目具有包的nuget引用 “Microsoft.NET.Test.Sdk”和框架版本设置 适当的使用/diag选项重新运行以进一步诊断。(……更多 此处,请参见下文)[警告]Vstest因错误而失败。检查日志 因为失败。可能有失败的测试。[错误]错误:C:\Program 文件(x86)\Microsoft Visual Studio Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe 失败,返回代码:1

所有测试项目都引用了
Microsoft.NET.test.Sdk
15.8.0。 MSTest.TestAdapter和MSTest.TestFramework都是v1.3.2


更新 如果我在本地运行
“C:\ProgramFiles(x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe”“path/to/dlls/X.Tests.dll”

我明白了

警告:(…)中没有可用的测试。确保已安装测试
发现者和执行者、平台和框架版本设置
请选择合适的,然后重试。

如果我运行
“C:\Program Files(x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\TestPlatform\vstest.console.exe”
,则不会出现警告,测试将运行

完整日志:

2018-08-28T00:00:45.6647912Z ##[section]Starting: Run Tests (without
IntegrationTests) 2018-08-28T00:00:45.6655596Z
============================================================================== 2018-08-28T00:00:45.6655734Z Task         : Visual Studio Test
2018-08-28T00:00:45.6655969Z Description  : Run unit and functional
tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio
Test (VsTest) runner. Test frameworks that have a Visual Studio test
adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests
using QUnit, Mocha and Jasmine), etc. can be run. Tests can be
distributed on multiple agents using this task (version 2).
2018-08-28T00:00:45.6656222Z Version      : 2.139.9
2018-08-28T00:00:45.6656325Z Author       : Microsoft Corporation
2018-08-28T00:00:45.6656441Z Help         : [More
Information](https://go.microsoft.com/fwlink/?LinkId=835764)
2018-08-28T00:00:45.6656579Z
==============================================================================2018-08-28T00:00:46.4686294Z SystemVssConnection exists true
2018-08-28T00:00:46.8053935Z SystemVssConnection exists true
2018-08-28T00:00:46.8765427Z Running tests using vstest.console.exe
runner. 2018-08-28T00:00:46.8765592Z
====================================================== 2018-08-28T00:00:46.8766130Z Test selector : Test assemblies
2018-08-28T00:00:46.8766339Z Test filter criteria :
TestCategory!=Nightly&TestCategory!=Integration
2018-08-28T00:00:46.8766639Z Search folder : D:\a\1\s
2018-08-28T00:00:46.8767889Z VisualStudio version selected for test
execution : latest 2018-08-28T00:00:46.9774487Z Run settings file :
undefined 2018-08-28T00:00:46.9856390Z Run in parallel : true
2018-08-28T00:00:46.9857604Z Run in isolation : false
2018-08-28T00:00:46.9858323Z Path to custom adapters : null
2018-08-28T00:00:46.9859693Z Other console options : null
2018-08-28T00:00:46.9860021Z Code coverage enabled : true
2018-08-28T00:00:46.9860217Z Diagnostics enabled : false
2018-08-28T00:00:46.9868731Z SystemVssConnection exists true
2018-08-28T00:00:46.9871063Z Run the tests locally using
vstest.console.exe 2018-08-28T00:00:46.9871397Z
======================================================== 2018-08-28T00:00:46.9871825Z Test selector : Test assemblies
2018-08-28T00:00:46.9879358Z Test assemblies :
**\XXX.*Test.dll,**\XXX.*Tests.dll 2018-08-28T00:00:46.9879772Z Test filter criteria : TestCategory!=Nightly&TestCategory!=Integration
2018-08-28T00:00:46.9880123Z Search folder : D:\a\1\s
2018-08-28T00:00:46.9880462Z Run settings file : D:\a\1\s
2018-08-28T00:00:46.9880914Z Run in parallel : true
2018-08-28T00:00:46.9881241Z Run in isolation : false
2018-08-28T00:00:46.9896387Z Path to custom adapters : null
2018-08-28T00:00:46.9898274Z Other console options : null
2018-08-28T00:00:46.9898473Z Code coverage enabled : true
2018-08-28T00:00:46.9898590Z Diagnostics enabled : false
2018-08-28T00:00:46.9898960Z Rerun failed tests: false
2018-08-28T00:00:46.9899597Z VisualStudio version selected for test
execution : latest 2018-08-28T00:00:47.8284246Z
======================================================== 2018-08-28T00:00:52.8242247Z
====================================================== 2018-08-28T00:00:57.9400998Z [command]"C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
@D:\a\_temp\6aed9fa1-aa55-11e8-bb9b-4d643c49ae03.txt
2018-08-28T00:01:00.8269632Z Microsoft (R) Test Execution Command Line
Tool Version 15.8.0 2018-08-28T00:01:00.8270417Z Copyright (c)
Microsoft Corporation.  All rights reserved.
2018-08-28T00:01:00.8270820Z  2018-08-28T00:01:00.8632494Z
vstest.console.exe  2018-08-28T00:01:00.8633358Z
"D:\a\1\s\src\XXX.YYY.IntegrationTests\bin\Release\netcoreapp2.1\XXX.YYY.IntegrationTests.dll"
2018-08-28T00:01:00.8633627Z
"D:\a\1\s\src\XXX.YYY.IntegrationTests\obj\Release\netcoreapp2.1\XXX.YYY.IntegrationTests.dll"
2018-08-28T00:01:00.8633953Z
"D:\a\1\s\src\XXX.YYY.ZZZ.IntegrationTests\bin\Release\netcoreapp2.1\XXX.YYY.IntegrationTests.dll"
2018-08-28T00:01:00.8636191Z
"D:\a\1\s\src\XXX.YYY.ZZZ.IntegrationTests\bin\Release\netcoreapp2.1\XXX.YYY.ZZZ.IntegrationTests.dll"
2018-08-28T00:01:00.8636472Z
"D:\a\1\s\src\XXX.YYY.ZZZ.IntegrationTests\obj\Release\netcoreapp2.1\XXX.YYY.ZZZ.IntegrationTests.dll"
2018-08-28T00:01:00.8636787Z
"D:\a\1\s\src\XXX.YYY.ZZZ.Tests\bin\Release\netcoreapp2.1\XXX.YYY.ZZZ.Tests.dll"
2018-08-28T00:01:00.8637041Z
"D:\a\1\s\src\XXX.YYY.ZZZ.Tests\obj\Release\netcoreapp2.1\XXX.YYY.ZZZ.Tests.dll"
2018-08-28T00:01:00.8637315Z
/TestCaseFilter:"TestCategory!=Nightly&TestCategory!=Integration"
2018-08-28T00:01:00.8637743Z
/Settings:"D:\a\_temp\6df3dac0-aa55-11e8-bb9b-4d643c49ae03.runsettings"
2018-08-28T00:01:00.8637935Z /EnableCodeCoverage
2018-08-28T00:01:00.8638256Z /logger:"trx"
2018-08-28T00:01:00.8638548Z /TestAdapterPath:"D:\a\1\s"
2018-08-28T00:01:03.1903254Z Starting test execution, please wait...
2018-08-28T00:01:08.9432858Z M i c r o s o f t   ( R )   C o v e r a g
e   C o l l e c t i o n   T o o l   V e r s i o n   1 5 . 0 . 3 0 3 1
9 . 0  2018-08-28T00:01:08.9433639Z   2018-08-28T00:01:08.9433873Z  
2018-08-28T00:01:08.9434477Z  C o p y r i g h t   ( c )   M i c r o s
o f t   C o r p o r a t i o n .     A l l   r i g h t s   r e s e r v
e d .  2018-08-28T00:01:08.9435073Z   2018-08-28T00:01:08.9435257Z  
2018-08-28T00:01:08.9435441Z   2018-08-28T00:01:08.9435606Z  
2018-08-28T00:01:08.9436502Z  M i c r o s o f t   ( R )   C o v e r a
g e   C o l l e c t i o n   T o o l   V e r s i o n   1 5 . 0 . 3 0 3
1 9 . 0  2018-08-28T00:01:08.9437228Z   2018-08-28T00:01:08.9437526Z  
2018-08-28T00:01:08.9438317Z  C o p y r i g h t   ( c )   M i c r o s
o f t   C o r p o r a t i o n .     A l l   r i g h t s   r e s e r v
e d .  2018-08-28T00:01:08.9443745Z   2018-08-28T00:01:08.9444075Z  
2018-08-28T00:01:08.9444447Z   2018-08-28T00:01:08.9445013Z  
2018-08-28T00:01:09.1360861Z  2.3895 2018-08-28T00:01:09.1382638Z
3.2133 2018-08-28T00:01:09.2952622Z System.IO.FileNotFoundException: Unable to find tests for
D:\a\1\s\src\XXX.YYY.IntegrationTests\obj\Release\netcoreapp2.1\XXX.YYY.IntegrationTests.dll.
Make sure test project has a nuget reference of package
"Microsoft.NET.Test.Sdk" and framework version settings are
appropriate. Rerun with /diag option to diagnose further.
2018-08-28T00:01:09.2953540Z    at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1
sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo
connectionInfo) 2018-08-28T00:01:09.2953958Z    at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1
sources) 2018-08-28T00:01:09.2954380Z    at
Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria
testRunCriteria, ITestRunEventsHandler eventHandler) ...(more of
'Unable to find tests' here) 2018-08-28T00:01:17.0497760Z  
2018-08-28T00:01:17.0497920Z   2018-08-28T00:01:17.0498091Z  
2018-08-28T00:01:18.7123301Z  Passed   Test1
2018-08-28T00:01:18.7123882Z Passed   Test1 (1.2.3.4,1002003004)
2018-08-28T00:01:18.7124151Z Passed   Test1 (1.5.14.0,1005014000)
...(more passed tests here) 2018-08-28T00:01:19.3916949Z M i c r o s o
f t   ( R )   C o v e r a g e   C o l l e c t i o n   T o o l   V e r
s i o n   1 5 . 0 . 3 0 3 1 9 . 0  2018-08-28T00:01:19.3918731Z  
2018-08-28T00:01:19.3919724Z   2018-08-28T00:01:19.3920819Z  C o p y r
i g h t   ( c )   M i c r o s o f t   C o r p o r a t i o n .     A l
l   r i g h t s   r e s e r v e d .  2018-08-28T00:01:19.3921474Z  
2018-08-28T00:01:19.3921706Z   2018-08-28T00:01:19.3921874Z  
2018-08-28T00:01:19.3922056Z   2018-08-28T00:01:19.4835444Z  Passed  
TestRossWorkingSetTrigger (50,True,0,False)
2018-08-28T00:01:19.4836131Z Passed   TestRossWorkingSetTrigger
(50,True,100,True) 2018-08-28T00:01:21.1779354Z Results File:
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az43_2018-08-28_00_01_18.trx
2018-08-28T00:01:21.1798304Z  2018-08-28T00:01:21.1801010Z
Attachments: 2018-08-28T00:01:21.1801324Z  
D:\a\1\s\TestResults\f1fe44c3-72d3-48e7-ba2f-99587f547b22\VssAdministrator_factoryvm-az43
2018-08-28 00_01_08.coverage 2018-08-28T00:01:21.1801492Z 
2018-08-28T00:01:21.1803157Z Total tests: Unknown. Passed: 76. Failed:
0. Skipped: 0. 2018-08-28T00:01:21.1805289Z Test Run Aborted. 2018-08-28T00:01:21.1814377Z Test execution time: 11.8839 Seconds
2018-08-28T00:01:21.2073077Z ##[warning]Vstest failed with error.
Check logs for failures. There might be failed tests.
2018-08-28T00:01:21.2456354Z ##[error]Error: C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
failed with return code: 1 2018-08-28T00:01:21.7575618Z
##[error]VsTest task failed. 2018-08-28T00:01:21.8006819Z ##[section]Async Command Start: Publish test results 2018-08-28T00:01:21.8288090Z Publishing test results to test run
'14831' 2018-08-28T00:01:21.8288284Z Test results remaining: 16. Test
run id: 14831 2018-08-28T00:01:22.9116908Z Published Test Run :
https://rbtech.visualstudio.com/XXX/_TestManagement/Runs#runId=14831&_a=runCharts
2018-08-28T00:01:22.9117351Z ##[section]Async Command End: Publish
test results 2018-08-28T00:01:22.9118586Z ##[section]Finishing: Run
Tests (without IntegrationTests)

提前感谢您的帮助。

根据错误消息和您在本地计算机上运行的命令,您的测试DLL中应该存在一些问题。请创建一个简单的单元测试项目,并使用VsTest任务运行此单元测试dll,以检查它是否也存在相同的问题。@WeiweiCai MSFT“根据错误消息和您在本地计算机上运行的命令,您的测试dll中应该存在一些问题”是什么意思?这说明了什么?如果我用一个版本的testrunner运行它,它会工作,如果用另一个版本运行它,它不会工作。这不是真正的问题。问题是测试运行了,但是构建被标记为失败,这是因为幻象导致的错误。我再强调也不过分,测试实际上是在运行的——它们怎么会丢失并同时运行呢?