From acfb51bba260822700090cdac4fb6fc60e7d08bb Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 12 Jun 2015 18:58:12 +0300 Subject: [PATCH] TKUnit: add exception guard and fail the test instead of crashing the app. --- apps/tests/TKUnit.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/tests/TKUnit.ts b/apps/tests/TKUnit.ts index ef4e4eee2..3c607b265 100644 --- a/apps/tests/TKUnit.ts +++ b/apps/tests/TKUnit.ts @@ -120,12 +120,15 @@ function runAsync(testInfo: TestInfoEntry, recursiveIndex: number, testTimeout?: } } - if (testInfo.instance) { - testInfo.testFunc.apply(testInfo.instance, [doneCallback]); - } - else { - var func: any = testInfo.testFunc; - func(doneCallback); + try { + if (testInfo.instance) { + testInfo.testFunc.apply(testInfo.instance, [doneCallback]); + } else { + var func: any = testInfo.testFunc; + func(doneCallback); + } + } catch (e) { + doneCallback(e); } setTimeout(checkFinished, 0); @@ -342,4 +345,4 @@ var doModalAndroid = function (quitLoop: () => boolean, timeoutSec: number) { quit = true; } } -}; \ No newline at end of file +};