mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
improved unit test reporting
This commit is contained in:
@ -31,6 +31,8 @@ export var runTestModule = function (module, moduleName) {
|
|||||||
|
|
||||||
var totalTests = 0;
|
var totalTests = 0;
|
||||||
var totalSuccess = 0;
|
var totalSuccess = 0;
|
||||||
|
var errors = new Array();
|
||||||
|
|
||||||
for (var testName in module) {
|
for (var testName in module) {
|
||||||
var testFunction = module[testName];
|
var testFunction = module[testName];
|
||||||
if ((typeof (testFunction) === "function") && (testName.substring(0, 4) == "test")) {
|
if ((typeof (testFunction) === "function") && (testName.substring(0, 4) == "test")) {
|
||||||
@ -46,6 +48,7 @@ export var runTestModule = function (module, moduleName) {
|
|||||||
runTest(testFunction, testName);
|
runTest(testFunction, testName);
|
||||||
totalSuccess++;
|
totalSuccess++;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
errors.push(e);
|
||||||
console.error("--- [" + testName + "] FAILED: " + e.message);
|
console.error("--- [" + testName + "] FAILED: " + e.message);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -68,6 +71,7 @@ export var runTestModule = function (module, moduleName) {
|
|||||||
|
|
||||||
console.timeEnd(moduleName);
|
console.timeEnd(moduleName);
|
||||||
console.info("--- " + moduleName + " TESTS COMPLETE --- (" + totalSuccess + " of " + totalTests + ") OK, " + (totalTests - totalSuccess) + " failed");
|
console.info("--- " + moduleName + " TESTS COMPLETE --- (" + totalSuccess + " of " + totalTests + ") OK, " + (totalTests - totalSuccess) + " failed");
|
||||||
|
return { "total": totalTests, "success": totalSuccess, "failed": (totalTests - totalSuccess), "errors": errors };
|
||||||
};
|
};
|
||||||
|
|
||||||
export var assert = function (test: any, message?: string) {
|
export var assert = function (test: any, message?: string) {
|
||||||
|
@ -10,11 +10,16 @@ allTests["IMAGE SOURCE"] = require("Tests/image-source-tests");
|
|||||||
allTests["TIMER"] = require("Tests/timer-tests");
|
allTests["TIMER"] = require("Tests/timer-tests");
|
||||||
|
|
||||||
export var runAll = function (moduleName?: string) {
|
export var runAll = function (moduleName?: string) {
|
||||||
|
var totalSuccess = 0;
|
||||||
|
var totalFailed = 0;
|
||||||
for (var name in allTests) {
|
for (var name in allTests) {
|
||||||
if(moduleName && (moduleName.toLowerCase() !== name.toLowerCase())) {
|
if(moduleName && (moduleName.toLowerCase() !== name.toLowerCase())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TKUnit.runTestModule(allTests[name], name);
|
var result = TKUnit.runTestModule(allTests[name], name);
|
||||||
|
totalSuccess += result.success;
|
||||||
|
totalFailed += result.failed;
|
||||||
}
|
}
|
||||||
|
console.info("=== ALL TESTS COMPLETE === " + totalSuccess + " OK, " + totalFailed + " failed")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user