| 369 | } |
| 370 | |
| 371 | function 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 | |
| 394 | function showReportPage(finalMessage: string) { |
| 395 | const stack = new StackLayout(); |