From ce340de8b981c032cb0e58920b6c84d41f554387 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 19 Jan 2023 13:52:46 +1100 Subject: [PATCH] Add reporter, eslint, formatting. --- README.md | 1 + action.yml | 1 + src/main.ts | 3 +++ src/parsers/dotnet-nunit/dotnet-nunit-parser.ts | 16 ++++++++-------- src/parsers/dotnet-nunit/dotnet-nunit-types.ts | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6d34e2c..c4de5e6 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ jobs: # Format of test results. Supported options: # dart-json + # dotnet-nunit # dotnet-trx # flutter-json # java-junit diff --git a/action.yml b/action.yml index 8d9d728..3ea90c1 100644 --- a/action.yml +++ b/action.yml @@ -26,6 +26,7 @@ inputs: description: | Format of test results. Supported options: - dart-json + - dotnet-nunit - dotnet-trx - flutter-json - java-junit diff --git a/src/main.ts b/src/main.ts index 8f481af..458d106 100644 --- a/src/main.ts +++ b/src/main.ts @@ -11,6 +11,7 @@ import {getAnnotations} from './report/get-annotations' import {getReport} from './report/get-report' 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 {JavaJunitParser} from './parsers/java-junit/java-junit-parser' import {JestJunitParser} from './parsers/jest-junit/jest-junit-parser' @@ -214,6 +215,8 @@ class TestReporter { switch (reporter) { case 'dart-json': return new DartJsonParser(options, 'dart') + case 'dotnet-nunit': + return new DotNetNunitParser(options) case 'dotnet-trx': return new DotnetTrxParser(options) case 'flutter-json': diff --git a/src/parsers/dotnet-nunit/dotnet-nunit-parser.ts b/src/parsers/dotnet-nunit/dotnet-nunit-parser.ts index 73a0438..70d3269 100644 --- a/src/parsers/dotnet-nunit/dotnet-nunit-parser.ts +++ b/src/parsers/dotnet-nunit/dotnet-nunit-parser.ts @@ -1,7 +1,7 @@ import {ParseOptions, TestParser} from '../../test-parser' 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 {getBasePath, normalizeFilePath} from '../../utils/path-utils' @@ -50,23 +50,23 @@ export class DotNetNunitParser implements TestParser { return } - testSuites.forEach(suite => { + for (const suite of testSuites) { suitePath.push(suite) this.populateTestCasesRecursive(result, suitePath, suite['test-suite']) const testcases = suite['test-case'] if (testcases !== undefined) { - testcases.forEach(testcase => { + for (const testcase of testcases) { this.addTestCase(result, suitePath, testcase) - }) + } } 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 rest are concatenated together to form the "suite". // But ignore "Theory" suites. @@ -125,8 +125,8 @@ export class DotNetNunitParser implements TestParser { } return { - path: path, - line: line, + path, + line, message: details.message && details.message.length > 0 ? details.message[0] : '', details: details['stack-trace'] && details['stack-trace'].length > 0 ? details['stack-trace'][0] : '' } diff --git a/src/parsers/dotnet-nunit/dotnet-nunit-types.ts b/src/parsers/dotnet-nunit/dotnet-nunit-types.ts index 3ac76c1..ec1696c 100644 --- a/src/parsers/dotnet-nunit/dotnet-nunit-types.ts +++ b/src/parsers/dotnet-nunit/dotnet-nunit-types.ts @@ -1,5 +1,5 @@ export interface NunitReport { - "test-run": TestRun + 'test-run': TestRun } export interface TestRun {