Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/guiunit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan McGovern <alan@xamarin.com>2013-07-23 10:29:17 +0400
committerAlan McGovern <alan@xamarin.com>2013-07-23 10:33:33 +0400
commit4dc929e08402fa5bf80aaf71209e2b8fed892e4e (patch)
tree17dc7d431fe9676c9efa7978850219eee6f5d792
parent51ae5cfcafd5a843cd86a182731472a17121835c (diff)
Add basic support for outputing on the fly updates
-rw-r--r--src/framework/GuiUnit/XmlTestListener.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/framework/GuiUnit/XmlTestListener.cs b/src/framework/GuiUnit/XmlTestListener.cs
new file mode 100644
index 0000000..e31286a
--- /dev/null
+++ b/src/framework/GuiUnit/XmlTestListener.cs
@@ -0,0 +1,61 @@
+using System;
+using NUnit.Framework.Api;
+using System.Xml.Linq;
+using System.IO;
+
+namespace GuiUnit
+{
+ public class XmlTestListener : ITestListener
+ {
+ TextWriter Writer {
+ get; set;
+ }
+
+ public XmlTestListener (TextWriter writer)
+ {
+ Writer = writer;
+ }
+
+ public void TestStarted (ITest test)
+ {
+ if (test.HasChildren)
+ Write (new XElement ("suite-started", new XAttribute ("name", test.FullName)));
+ else
+ Write (new XElement ("test-started", new XAttribute ("name", test.FullName)));
+ }
+
+ public void TestFinished (ITestResult result)
+ {
+ if (result.Test.HasChildren)
+ Write (new XElement ("suite-finished", new XAttribute ("name", result.Test.FullName), new XAttribute ("result", ToXmlString (result.ResultState))));
+ else
+ Write (new XElement ("test-finished", new XAttribute ("name", result.Test.FullName), new XAttribute ("result", ToXmlString (result.ResultState))));
+ }
+
+ public void TestOutput (TestOutput testOutput)
+ {
+ // Ignore
+ }
+
+ object ToXmlString (ResultState resultState)
+ {
+ if (resultState == ResultState.Success)
+ return "Success";
+ else if (resultState == ResultState.Inconclusive)
+ return "Inconclusive";
+ else if (resultState == ResultState.Ignored)
+ return "Ignored";
+ else
+ return "Failure";
+ }
+
+ void Write (XElement element)
+ {
+ try {
+ Writer.WriteLine (element.ToString ());
+ } catch {
+ }
+ }
+ }
+}
+