Lines Matching refs:results

33          * Returns test results formatted as a JSON string. Requires JSON utility.

34 * @param {Object} result The results object created by TestRunner.
35 * @return {String} A JSON-formatted string of results.
39 JSON: function(results) {
40 return YUITest.Util.JSON.stringify(results);
44 * Returns test results formatted as an XML string.
45 * @param {Object} result The results object created by TestRunner.
46 * @return {String} An XML-formatted string of results.
50 XML: function(results) {
52 function serializeToXML(results){
53 var xml = "<" + results.type + " name=\"" + xmlEscape(results.name) + "\"";
55 if (typeof(results.duration)=="number"){
56 xml += " duration=\"" + results.duration + "\"";
59 if (results.type == "test"){
60 xml += " result=\"" + results.result + "\" message=\"" + xmlEscape(results.message) + "\">";
62 xml += " passed=\"" + results.passed + "\" failed=\"" + results.failed + "\" ignored=\"" + results.ignored + "\" total=\"" + results.total + "\">";
63 for (var prop in results){
64 if (results.hasOwnProperty(prop)){
65 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
66 xml += serializeToXML(results[prop]);
72 xml += "</" + results.type + ">";
77 return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + serializeToXML(results);
83 * Returns test results formatted in JUnit XML format.
84 * @param {Object} result The results object created by TestRunner.
85 * @return {String} An XML-formatted string of results.
89 JUnitXML: function(results) {
91 function serializeToJUnitXML(results){
94 switch (results.type){
97 if (results.result != "ignore"){
98 xml = "<testcase name=\"" + xmlEscape(results.name) + "\" time=\"" + (results.duration/1000) + "\">";
99 if (results.result == "fail"){
100 xml += "<failure message=\"" + xmlEscape(results.message) + "\"><![CDATA[" + results.message + "]]></failure>";
109 xml = "<testsuite name=\"" + xmlEscape(results.name) + "\" tests=\"" + results.total + "\" failures=\"" + results.failed + "\" time=\"" + (results.duration/1000) + "\">";
111 for (var prop in results){
112 if (results.hasOwnProperty(prop)){
113 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
114 xml += serializeToJUnitXML(results[prop]);
124 for (var prop in results){
125 if (results.hasOwnProperty(prop)){
126 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
127 xml += serializeToJUnitXML(results[prop]);
138 for (var prop in results){
139 if (results.hasOwnProperty(prop)){
140 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
141 xml += serializeToJUnitXML(results[prop]);
155 return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + serializeToJUnitXML(results);
159 * Returns test results formatted in TAP format.
161 * @param {Object} result The results object created by TestRunner.
162 * @return {String} A TAP-formatted string of results.
166 TAP: function(results) {
170 function serializeToTAP(results){
173 switch (results.type){
176 if (results.result != "ignore"){
178 text = "ok " + (currentTestNum++) + " - " + results.name;
180 if (results.result == "fail"){
181 text = "not " + text + " - " + results.message;
186 text = "#Ignored test " + results.name + "\n";
192 text = "#Begin testcase " + results.name + "(" + results.failed + " failed of " + results.total + ")\n";
194 for (var prop in results){
195 if (results.hasOwnProperty(prop)){
196 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
197 text += serializeToTAP(results[prop]);
202 text += "#End testcase " + results.name + "\n";
209 text = "#Begin testsuite " + results.name + "(" + results.failed + " failed of " + results.total + ")\n";
211 for (var prop in results){
212 if (results.hasOwnProperty(prop)){
213 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
214 text += serializeToTAP(results[prop]);
219 text += "#End testsuite " + results.name + "\n";
224 for (var prop in results){
225 if (results.hasOwnProperty(prop)){
226 if (results[prop] && typeof results[prop] == "object" && !(results[prop] instanceof Array)){
227 text += serializeToTAP(results[prop]);
239 return "1.." + results.total + "\n" + serializeToTAP(results);