Add reporter, eslint, formatting.

This commit is contained in:
Kevin Ring 2023-01-19 13:52:46 +11:00 committed by Jozef Izso
parent 953e623fd8
commit ce340de8b9
5 changed files with 14 additions and 9 deletions

View file

@ -137,6 +137,7 @@ jobs:
# Format of test results. Supported options: # Format of test results. Supported options:
# dart-json # dart-json
# dotnet-nunit
# dotnet-trx # dotnet-trx
# flutter-json # flutter-json
# java-junit # java-junit

View file

@ -26,6 +26,7 @@ inputs:
description: | description: |
Format of test results. Supported options: Format of test results. Supported options:
- dart-json - dart-json
- dotnet-nunit
- dotnet-trx - dotnet-trx
- flutter-json - flutter-json
- java-junit - java-junit

View file

@ -11,6 +11,7 @@ import {getAnnotations} from './report/get-annotations'
import {getReport} from './report/get-report' import {getReport} from './report/get-report'
import {DartJsonParser} from './parsers/dart-json/dart-json-parser' import {DartJsonParser} from './parsers/dart-json/dart-json-parser'
import {DotNetNunitParser} from './parsers/dotnet-nunit/dotnet-nunit-parser'
import {DotnetTrxParser} from './parsers/dotnet-trx/dotnet-trx-parser' import {DotnetTrxParser} from './parsers/dotnet-trx/dotnet-trx-parser'
import {JavaJunitParser} from './parsers/java-junit/java-junit-parser' import {JavaJunitParser} from './parsers/java-junit/java-junit-parser'
import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser' import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser'
@ -214,6 +215,8 @@ class TestReporter {
switch (reporter) { switch (reporter) {
case 'dart-json': case 'dart-json':
return new DartJsonParser(options, 'dart') return new DartJsonParser(options, 'dart')
case 'dotnet-nunit':
return new DotNetNunitParser(options)
case 'dotnet-trx': case 'dotnet-trx':
return new DotnetTrxParser(options) return new DotnetTrxParser(options)
case 'flutter-json': case 'flutter-json':

View file

@ -1,7 +1,7 @@
import {ParseOptions, TestParser} from '../../test-parser' import {ParseOptions, TestParser} from '../../test-parser'
import {parseStringPromise} from 'xml2js' import {parseStringPromise} from 'xml2js'
import {NunitReport, TestCase, TestRun, TestSuite} from './dotnet-nunit-types' import {NunitReport, TestCase, TestSuite} from './dotnet-nunit-types'
import {getExceptionSource} from '../../utils/node-utils' import {getExceptionSource} from '../../utils/node-utils'
import {getBasePath, normalizeFilePath} from '../../utils/path-utils' import {getBasePath, normalizeFilePath} from '../../utils/path-utils'
@ -50,23 +50,23 @@ export class DotNetNunitParser implements TestParser {
return return
} }
testSuites.forEach(suite => { for (const suite of testSuites) {
suitePath.push(suite) suitePath.push(suite)
this.populateTestCasesRecursive(result, suitePath, suite['test-suite']) this.populateTestCasesRecursive(result, suitePath, suite['test-suite'])
const testcases = suite['test-case'] const testcases = suite['test-case']
if (testcases !== undefined) { if (testcases !== undefined) {
testcases.forEach(testcase => { for (const testcase of testcases) {
this.addTestCase(result, suitePath, testcase) this.addTestCase(result, suitePath, testcase)
}) }
} }
suitePath.pop() suitePath.pop()
}) }
} }
private addTestCase(result: TestSuiteResult[], suitePath: TestSuite[], testCase: TestCase) { private addTestCase(result: TestSuiteResult[], suitePath: TestSuite[], testCase: TestCase): void {
// The last suite in the suite path is the "group". // The last suite in the suite path is the "group".
// The rest are concatenated together to form the "suite". // The rest are concatenated together to form the "suite".
// But ignore "Theory" suites. // But ignore "Theory" suites.
@ -125,8 +125,8 @@ export class DotNetNunitParser implements TestParser {
} }
return { return {
path: path, path,
line: line, line,
message: details.message && details.message.length > 0 ? details.message[0] : '', message: details.message && details.message.length > 0 ? details.message[0] : '',
details: details['stack-trace'] && details['stack-trace'].length > 0 ? details['stack-trace'][0] : '' details: details['stack-trace'] && details['stack-trace'].length > 0 ? details['stack-trace'][0] : ''
} }

View file

@ -1,5 +1,5 @@
export interface NunitReport { export interface NunitReport {
"test-run": TestRun 'test-run': TestRun
} }
export interface TestRun { export interface TestRun {