Parcourir la source

* Patch from Dean Zobec to fix the XMLreporter

git-svn-id: trunk@4773 -
michael il y a 19 ans
Parent
commit
847377bf79
2 fichiers modifiés avec 29 ajouts et 27 suppressions
  1. 1 1
      fcl/fpcunit/demo/consolerunner/testrunner.pp
  2. 28 26
      fcl/fpcunit/xmlreporter.pas

+ 1 - 1
fcl/fpcunit/demo/consolerunner/testrunner.pp

@@ -17,7 +17,7 @@ program testrunner;
 {$h+}
 
 uses
-  custapp, Classes, SysUtils, fpcunit, suiteconfig, xmlreporter, testregistry;
+  custapp, Classes, SysUtils, fpcunit, suiteconfig, testreport, testregistry;
 
 
 const

+ 28 - 26
fcl/fpcunit/xmlreporter.pas

@@ -149,41 +149,43 @@ end;
 
 
 procedure TXMLResultsWriter.AddFailure(ATest: TTest; AFailure: TTestFailure);
-  procedure GenerateNode(aNode: TDOMNode);
-  var
-    n: TDOMElement;
-    s: string;
+var
+  n: TDOMElement;
+begin
+  if AFailure.IsIgnoredTest then
   begin
-    if AFailure.IsIgnoredTest then 
-      s := 'ListOfIgnoredTests'
-    else
-      s := 'ListOfFailures';
     { Try and find the node first }
-    if not Assigned(aNode) then
-      aNode := FDoc.FindNode(s);
+    if not Assigned(FIgnores) then
+      FIgnores := FDoc.FindNode('ListOfIgnoredTests');
     { If we couldn't find it, create it }
-    if not Assigned(aNode) then
+    if not Assigned(FIgnores) then
     begin
-      aNode := FDoc.CreateElement(s);
-      FResults.AppendChild(aNode);
+      FIgnores := FDoc.CreateElement('ListOfIgnoredTests');
+      FResults.AppendChild(FIgnores);
     end;
-
-    if AFailure.IsIgnoredTest then 
-      s := 'IgnoredTest'
-    else
-      s := 'Failure';
-    n := FDoc.CreateElement(s);
+    n := FDoc.CreateElement('IgnoredTest');
     n.AppendChild(FDoc.CreateElement('Message')         ).AppendChild(FDoc.CreateTextNode(AFailure.AsString));
     n.AppendChild(FDoc.CreateElement('ExceptionClass')  ).AppendChild(FDoc.CreateTextNode(AFailure.ExceptionClassName));
     n.AppendChild(FDoc.CreateElement('ExceptionMessage')).AppendChild(FDoc.CreateTextNode(AFailure.ExceptionMessage));
-    aNode.AppendChild(n);
-  end;
-
-begin
-  if AFailure.IsIgnoredTest then
-    GenerateNode(FIgnores)
+    FIgnores.AppendChild(n);
+  end
   else
-    GenerateNode(FFailures);
+    begin
+      { Try and find the node first }
+      if not Assigned(FFailures) then
+      FFailures := FDoc.FindNode('ListOfFailures');
+      { If we couldn't find it, create it }
+      if not Assigned(FFailures) then
+      begin
+        FFailures := FDoc.CreateElement('ListOfFailures');
+        FResults.AppendChild(FFailures);
+      end;
+      n := FDoc.CreateElement('Failure');
+      n.AppendChild(FDoc.CreateElement('Message')         ).AppendChild(FDoc.CreateTextNode(AFailure.AsString));
+      n.AppendChild(FDoc.CreateElement('ExceptionClass')  ).AppendChild(FDoc.CreateTextNode(AFailure.ExceptionClassName));
+      n.AppendChild(FDoc.CreateElement('ExceptionMessage')).AppendChild(FDoc.CreateTextNode(AFailure.ExceptionMessage));
+      FFailures.AppendChild(n);
+    end;
 end;