vstest.console.exe在UWP单元测试项目中崩溃"根级别的数据无效。"

时间:2018-01-27 14:41:12

标签: unit-testing tfs uwp azure-devops mstest

尝试使用vstest.console.exe运行UWP单元测试项目,我使用MSBuild生成appx包,并调用:

app.post("/follow", function(req, res){
    var follow = {follower_id:currentUser.id, followee_id:user_id};

    connection.query('INSERT INTO follows SET ?', follow , function(err, result) {
        if (err) throw err;
        res.redirect("/");
    });
});

但是得到:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform> ./vstest.console.exe C:\builds\droplocation\Uwp.UnitTesting\AppPackages\Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\wp.UnitTesting_1.0.0.0_x86_Debug.appx

当我更改Microsoft (R) Test Execution Command Line Tool Version 15.5.0 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait... Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\builds\droplocation\RS.Uwp.UnitTesting\AppPackages\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at Microsoft.Build.Internal.XmlReaderExtension.GetXmlReader(StreamReader input, Encoding& encoding) at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file) at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting) --- End of inner exception stack trace --- at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args) at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass200_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache) at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean isExplicitlyLoaded) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion) at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_Project() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_LayoutPath() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.Microsoft.VisualStudio.UwpTestHostRuntimeProvider.IDeployer.Deploy() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<LaunchHostAsync>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<Microsoft-VisualStudio-TestPlatform-ObjectModel-Host-ITestRuntimeProvider-LaunchTestHostAsync>d__30.MoveNext() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken) ---> (Inner Exception #0) Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1. C:\builds\droplocation\RS.Uwp.UnitTesting\AppPackages\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug_Test\RS.Uwp.UnitTesting_1.0.0.0_x86_Debug.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String arg) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.XmlTextReader.Read() at Microsoft.Build.Internal.XmlReaderExtension.GetXmlReader(StreamReader input, Encoding& encoding) at Microsoft.Build.Internal.XmlReaderExtension..ctor(String file) at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting) --- End of inner exception stack trace --- at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args) at Microsoft.Build.Construction.ProjectRootElement.LoadDocument(String fullPath, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement..ctor(String path, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.CreateProjectFromPath(String projectFile, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.<>c__DisplayClass200_0.<OpenProjectOrSolution>b__0(String path, ProjectRootElementCache cache) at Microsoft.Build.Evaluation.ProjectRootElementCache.Get(String projectFile, OpenProjectRootElement openProjectRootElement, Boolean isExplicitlyLoaded, Nullable`1 preserveFormatting) at Microsoft.Build.Construction.ProjectRootElement.OpenProjectOrSolution(String fullPath, IDictionary`2 globalProperties, String toolsVersion, ProjectRootElementCache projectRootElementCache, Boolean isExplicitlyLoaded) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion) at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_Project() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.RecipeFile.get_LayoutPath() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.Deployer.Microsoft.VisualStudio.UwpTestHostRuntimeProvider.IDeployer.Deploy() at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<LaunchHostAsync>d__35.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.UwpTestHostRuntimeProvider.UwpTestHostManager.<Microsoft-VisualStudio-TestPlatform-ObjectModel-Host-ITestRuntimeProvider-LaunchTestHostAsync>d__30.MoveNext()<--- Test Run Aborted. lcoation时:

vstest.console.exe

为:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\Extensions\TestPlatform

它适用于使用VS2017 Professional的本地计算机,但在使用删除构建服务器上的构建代理程序调用时,它仍然是相同的:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TestWindow

奇怪的是,当我尝试在构建服务器上手动运行它时,它崩溃了以下输出:

******************************************************************************
Starting: VsTest - UWP
******************************************************************************
==============================================================================
Task         : Visual Studio Test
Description  : Run tests with Visual Studio test runner
Version      : 2.3.8
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=835764)
==============================================================================
Run the tests locally using vstest.console.exe
========================================================
Test selector : Test assemblies
Test assemblies : C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx
Test filter criteria : null
Search folder : C:\agent\_work\2\s
Run settings file : C:\agent\_work\2\s
Run in parallel : false
Run in isolation : true
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Rerun failed tests: false
vstest.console.exe, specified location : C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow
========================================================
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" @C:\agent\_work\_temp\635f6641-039f-11e8-b3d5-d35598e183b1.txt
Microsoft (R) Test Execution Command Line Tool Version 15.5.0
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe 
"C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx"
/InIsolation
/logger:"trx"
/TestAdapterPath:"C:\agent\_work\2\s"
Starting test execution, please wait...
Failed to launch testhost with error: System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.InvalidProjectFileException: The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.  C:\agent\_work\2\a\AppxPackages\Uwp.UnitTesting_1.0.0.0_x86_Test\Uwp.UnitTesting_1.0.0.0_x86.appx ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

0 个答案:

没有答案