nunit / nunitv2

NUnit 2.x repository. NUnit V2 IS NO LONGER MAINTAINED OR UPDATED. Bugs should be reported in the main NUnit 3.0 repository.
https://github.com/nunit/nunit
Other
25 stars 26 forks source link

Assert.Pass() with ]]> in message crashes console runner #28

Closed CharliePoole closed 9 years ago

CharliePoole commented 9 years ago

[This issue was erroneously filed under the former nunit-console project by @mhalenar.]

NUnit-Console version 2.6.3.13283 Runtime Environment - OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1 CLR Version: 4.0.30319.18408 ( Net 4.5 ) ProcessModel: Default DomainUsage: Single Execution Runtime: net-4.5

Hi, when i call in test Assert.Pass("bla]]>"), console runner crashes without producing TestResults.xml with following exception: Test 'Test1' finished as Passed!

Unhandled Exception: System.ArgumentException: Cannot have ']]>' inside an XML CDATA block. at System.Xml.XmlTextWriter.WriteCData(String text) at NUnit.Util.XmlResultWriter.WriteReasonElement(TestResult result) at NUnit.Util.XmlResultWriter.WriteResultElement(TestResult result) at NUnit.Util.XmlResultWriter.WriteChildResults(TestResult result) at NUnit.Util.XmlResultWriter.WriteResultElement(TestResult result) at NUnit.Util.XmlResultWriter.WriteChildResults(TestResult result) at NUnit.Util.XmlResultWriter.WriteResultElement(TestResult result) at NUnit.Util.XmlResultWriter.WriteChildResults(TestResult result) at NUnit.Util.XmlResultWriter.WriteResultElement(TestResult result) at NUnit.Util.XmlResultWriter.WriteChildResults(TestResult result) at NUnit.Util.XmlResultWriter.WriteResultElement(TestResult result) at NUnit.Util.XmlResultWriter.SaveTestResult(TestResult result) at NUnit.ConsoleRunner.ConsoleUi.CreateXmlOutput(TestResult result) at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options) at NUnit.ConsoleRunner.Runner.Main(String[] args)

However, putting same string to Assert.Fail is ok, runner correctly handles the output. Thanks.

Regards, Milan

CharliePoole commented 9 years ago

@rprouse : Easy fix: XmlResultWriter calls XmlWriter.WriteCData for the reason element but uses its own WriteCData method for the failure element, correctly handling this case.

Please check for any other CData elements we write in this class.

Please also check if we need to add this as an issue to 3.0.