Skip to content

Commit

Permalink
Add reporter, eslint, formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Ring authored and Jozef Izso committed Jun 25, 2024
1 parent 953e623 commit ce340de
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
# Format of test results. Supported options:
# dart-json
# dotnet-nunit
# dotnet-trx
# flutter-json
# java-junit
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ inputs:
description: |
Format of test results. Supported options:
- dart-json
- dotnet-nunit
- dotnet-trx
- flutter-json
- java-junit
Expand Down
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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':
Expand Down
16 changes: 8 additions & 8 deletions src/parsers/dotnet-nunit/dotnet-nunit-parser.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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] : ''
}
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/dotnet-nunit/dotnet-nunit-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface NunitReport {
"test-run": TestRun
'test-run': TestRun
}

export interface TestRun {
Expand Down

0 comments on commit ce340de

Please sign in to comment.