Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\u001a test case fails on dotnet6 #1349

Open
indy-singh opened this issue Jun 27, 2023 · 5 comments
Open

\u001a test case fails on dotnet6 #1349

indy-singh opened this issue Jun 27, 2023 · 5 comments

Comments

@indy-singh
Copy link

[TestCase("\u001a")]
public void Then(string foo) => Assert.Pass();

The above testcase works fine on net472 + NUnit Console 3.16.3 (Release).

But it fails on dotnet6.0 + NUnit Console 3.16.3 (Release):-

With this exception:-

--XmlException
'�', hexadecimal value 0x1A, is an invalid character. Line 1, position 1571.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ThrowInvalidChar(Char[] data, Int32 length, Int32 invCharPos)
   at System.Xml.XmlTextReaderImpl.ParseCDataOrComment(XmlNodeType type, Int32& outStartPos, Int32& outEndPos)
   at System.Xml.XmlTextReaderImpl.ParseCDataOrComment(XmlNodeType type)
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace)
   at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
   at System.Xml.XmlDocument.Load(XmlReader reader)
   at System.Xml.XmlDocument.LoadXml(String xml)
   at NUnit.XmlHelper.CreateXmlNode(String xml)
   at NUnit.Engine.Runners.WorkItemTracker.NUnit.Engine.ITestEventListener.OnTestEvent(String report)
   at NUnit.Engine.Runners.TestEventDispatcher.OnTestEvent(String report)
   at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)
   at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
   at NUnit.ConsoleRunner.Program.Main(String[] args)

Cheers,
Indy

indy-singh added a commit to indy-singh/nunit_console_runner_issue_1349 that referenced this issue Jun 27, 2023
@indy-singh
Copy link
Author

@ueli-werner
Copy link

This is more likely a breaking change by Microsoft between Framework 4.7.2 and NET 6.

In my opinion this is not a bug in NUnit. The argument is a dotnet string and should be valid. Consider changing the argument type.

@manfred-brands
Copy link
Member

The string is a valid .NET string, just not valid inside XML CDATA where characters are limited to:
image

This excludes 0x1A.

Having said that, dotnet test has no problem with this
However even though tests are shown in Visual Studio Test Explorer.
image

They don't seem to run. I see error message: NUnit3TestExecutor discovered 0 of 0 NUnit test cases using Current Discovery mode, Explicit run

I don't know if the XML is NUnit specific or dictated by the test specification.
If arguments are stored there, they must be stored in such a way that they result in valid XML. Maybe they need encoding.

@andrewimcclement
Copy link

Presumably there is a suitable escape mechanism we can use when creating the XML in the first place?

@mikkelbu
Copy link
Member

mikkelbu commented Feb 2, 2024

I think the XML is NUnit specific and the framework have special code to handle this - see e.g. https://github.com/nunit/nunit/blob/68d994772d10de54ac960ea8379ee966a3293083/src/NUnitFramework/framework/XmlExtensions.cs#L76 - but apparent we also need some escaping in the engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants