SASUnit Examples  Version 1.3.0
_reportcreatetagset.sas
Go to the documentation of this file.
1 
19 %MACRO _reportCreateTagset;
20 
21  PROC TEMPLATE;
22  define tagset tagsets.JUnit_XML;
23  indent=3;
24 
25  define event doc;
26  start:
27  put '<?xml version="1.0" encoding="ISO-8859-1" ?>' NL;
28  put '<testsuites>' NL;
29  finish:
30  trigger handleOpenTestsuite;
31  put '</testsuites>' NL;
32  end;
33 
34  define event row;
35  finish: /* Output the current row-data gathered within the event 'data' and stored within the associative array 'myRow' */
36  trigger printScenario / if cmp($myRow["isScenario"], "1");
37  trigger printTestcase / if cmp($myRow["isScenario"], "0");
38  UNSET $myRow;
39  UNSET $failuresUnformatted;
40  end;
41 
42  define event data;
43  /* Store the data of each cell of the current row in the associative array 'myRow' for outputing it in the row.finish-event */
44  SET $myRow[NAME] VALUE;
45  SET $failuresUnformatted UNFORMATTEDVALUE / if cmp(NAME,"failures");
46  end;
47 
48  define event handleOpenTestsuite;
49  DO / if cmp($hasOpenTestsuite, "1");
50  put '</testsuite>' NL;
51  XDENT;
52  set $hasOpenTestsuite "0";
53  DONE;
54  end;
55 
56  define event printScenario;
57  trigger handleOpenTestsuite;
58  NDENT;
59  put '<testsuite' NL;
60  put ' tests ="' compress($myRow['tests']) '"' NL;
61  put ' failures ="' compress($myRow['failures']) '"' NL;
62  put ' id ="' $myRow['id'] '"' NL;
63  put ' name ="' $myRow['name'] '"' NL;
64  put ' package ="' $myRow['classname'] '"' NL;
65  put ' time ="' compress($myRow['time']) '"' NL;
66  put ' timestamp ="' $myRow['timestamp'] '"' NL;
67  put '>' NL;
68  SET $hasOpenTestsuite "1";
69  end;
70 
71  define event printTestcase;
72  NDENT;
73  put '<testcase' NL;
74  put ' classname ="' $myRow['classname'] '"' NL;
75  put ' name ="' $myRow['name'] '"' NL;
76  put ' time ="' compress($myRow['time']) '"' NL;
77  put ' timestamp ="' $myRow['timestamp'] '"' NL;
78  put ' id ="' $myRow['id'] '"' NL;
79  DO / if ^cmp($failuresUnformatted, "0");
80  put '>' NL;
81  trigger printFailure;
82  put '</testcase>' NL;
83  ELSE;
84  put ' />' NL;
85  DONE;
86  XDENT;
87  end;
88 
89  define event printFailure;
90  NDENT;
91  put '<failure' NL;
92  put ' message ="' $myRow['message'] '"' NL;
93  put ' type = "' $myRow['type'] '"' NL;
94  PUT '>' $myRow['message'] '</failure>' NL;
95  XDENT;
96  end;
97  end;
98  RUN; /* PROC TEMPLATE */
99 
100 %MEND _reportCreateTagset;
101