TestFormat.js revision bb6e451d9b8cf6421394062b7e49a9674265058b
Y.namespace("Test.Format");
/* (intentionally not documented)
* Basic XML escaping method. Replaces quotes, less-than, greater-than,
* apostrophe, and ampersand characters with their corresponding entities.
* @param {String} text The text to encode.
* @return {String} The XML-escaped text.
*/
switch(value){
case "\"": return """;
case "'": return "'";
case "&": return "&";
}
});
}
/**
* Returns test results formatted as a JSON string. Requires JSON utility.
* @param {Object} result The results object created by TestRunner.
* @return {String} A JSON-formatted string of results.
* @namespace Test.Format
* @method JSON
* @static
*/
};
/**
* Returns test results formatted as an XML string.
* @param {Object} result The results object created by TestRunner.
* @return {String} An XML-formatted string of results.
* @namespace Test.Format
* @method XML
* @static
*/
function serializeToXML(results){
var l = Y.Lang,
}
} else {
xml += " passed=\"" + results.passed + "\" failed=\"" + results.failed + "\" ignored=\"" + results.ignored + "\" total=\"" + results.total + "\">";
}
});
}
return xml;
}
};
/**
* Returns test results formatted in JUnit XML format.
* @param {Object} result The results object created by TestRunner.
* @return {String} An XML-formatted string of results.
* @namespace Test.Format
* @method JUnitXML
* @static
*/
function serializeToJUnitXML(results){
var l = Y.Lang,
xml = "",
prop;
//equivalent to testcase in JUnit
case "test":
xml += "<failure message=\"" + xmlEscape(results.message) + "\"><![CDATA[" + results.message + "]]></failure>";
}
xml+= "</testcase>";
}
break;
//equivalent to testsuite in JUnit
case "testcase":
xml = "<testsuite name=\"" + xmlEscape(results.name) + "\" tests=\"" + results.total + "\" failures=\"" + results.failed + "\">";
}
});
xml += "</testsuite>";
break;
case "testsuite":
}
});
//skip output - no JUnit equivalent
break;
case "report":
xml = "<testsuites>";
}
});
xml += "</testsuites>";
//no default
}
return xml;
}
};