Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.Xml.xmlDotnet测试发生异常_C#_.net_Unit Testing_.net Core_Xunit - Fatal编程技术网

C# System.Xml.xmlDotnet测试发生异常

C# System.Xml.xmlDotnet测试发生异常,c#,.net,unit-testing,.net-core,xunit,C#,.net,Unit Testing,.net Core,Xunit,使用.NET Core的单元测试功能以及MSTest框架和适配器,我尝试运行以下简单的单元测试: using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TESTFull { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { A

使用.NET Core的单元测试功能以及MSTest框架和适配器,我尝试运行以下简单的单元测试:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TESTFull
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.AreEqual(1, 2);
        }
    }
}
但是,即使使用脚手架依赖项:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
    <PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
  </ItemGroup>
</Project>

请注意,空的
TestMethod1()
以及使用内置的xUnit项目模板时都会发生此错误。我正在使用.NET Core 1.1。

我无法使用
MSTest
XUnit
重现此问题。可能要查看的区域是
PackageReference
版本,尤其是
MSTest
XUnit
。在
Nuget
中查找您的版本,并验证.net标准it支持的版本。

问题在于您的文件路径。目前,
dotnet test
无法处理包含符号(即
&
字符)的文件路径。

我尝试使用其他版本。你用的是什么版本?
Test run for F:\Onedrive\Uni\2-1\Dev Project 1 - Tools & Practices\RESTFull\TESTFull\bin\Debug\netcoreapp1.1\TESTFull.dll(.NETCoreApp,Version=v1.1)
Microsoft (R) Test Execution Command Line Tool Version 15.0.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Unhandled Exception: System.Xml.XmlException: An error occurred while parsing EntityName. Line 1, position 44.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.Throw(String res, Int32 lineNo, Int32 linePos)
   at System.Xml.XmlTextReaderImpl.HandleEntityReference(Boolean isInAttributeValue, EntityExpandType expandType, Int32& charRefEndPos)
   at System.Xml.XmlTextReaderImpl.ParseText(Int32& startPos, Int32& endPos, Int32& outOrChars)
   at System.Xml.XmlTextReaderImpl.FinishPartialValue()
   at System.Xml.XmlTextReaderImpl.get_Value()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.ParsePartialContent(XmlNode parentNode, String innerxmltext, XmlNodeType nt)
   at System.Xml.XmlLoader.LoadInnerXmlElement(XmlElement node, String innerxmltext)
   at System.Xml.XmlElement.set_InnerXml(String value)
   at Microsoft.VisualStudio.TestPlatform.Utilities.XmlUtilities.AppendOrModifyChild(XPathNavigator parentNavigator, String nodeXPath, String nodeName, String innerXml)
   at Microsoft.VisualStudio.TestPlatform.Utilities.InferRunSettingsHelper.UpdateRunConfiguration(XPathNavigator navigator, Architecture effectivePlatform, Framework effectiveFramework, String resultsDirectory)
   at Microsoft.VisualStudio.TestPlatform.Utilities.InferRunSettingsHelper.UpdateRunSettingsWithUserProvidedSwitches(XPathNavigator runSettingsNavigator, Architecture architecture, Framework framework, String resultsDirectory)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities.RunSettingsUtilities.GetEffectiveRunSettings(String runSettings, CommandLineOptions commandLineOptions)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities.RunSettingsUtilities.GetRunSettings(IRunSettingsProvider runSettingsProvider, CommandLineOptions commandlineOptions)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentExecutor.RunTests(IEnumerable`1 sources)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.RunTestsArgumentExecutor.Execute()
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.ExecuteArgumentProcessor(IArgumentProcessor processor, Int32& exitCode)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Executor.Execute(String[] args)
   at Microsoft.VisualStudio.TestPlatform.CommandLine.Program.Main(String[] args)