MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / generateTestFile

Function generateTestFile

apps/automated/src/test-runner.ts:371–392  ·  view source on GitHub ↗
(allTests: TestInfo[])

Source from the content-addressed store, hash-verified

369}
370
371function generateTestFile(allTests: TestInfo[]) {
372 let failedTestCount = 0;
373
374 const testCases = new Array<string>();
375 allTests.forEach((testCase, i, arr) => {
376 let testName = testCase.testName;
377 let duration = (testCase.duration / 1000).toFixed(2);
378
379 testCases.push(`<testcase classname="${Device.os}" name="${testName}" time="${duration}">`);
380 if (!testCase.isPassed) {
381 failedTestCount++;
382 testCases.push(`<failure type="exceptions.AssertionError"><![CDATA[${testCase.errorMessage}]]></failure>`);
383 }
384 testCases.push(`</testcase>`);
385 });
386
387 const totalTime = (TKUnit.time() - startTime).toFixed(2);
388
389 const result = ['<testsuites>', `<testsuite name="NativeScript Tests" timestamp="${new Date()}" hostname="hostname" time="${totalTime}" errors="0" tests="${allTests.length}" skipped="0" failures="${failedTestCount}">`, ...testCases, '</testsuite>', '</testsuites>'].join('');
390
391 return result;
392}
393
394function showReportPage(finalMessage: string) {
395 const stack = new StackLayout();

Callers

nothing calls this directly

Calls 4

forEachMethod · 0.80
timeMethod · 0.80
joinMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected