feat: add reporter for salesforce apex

This commit is contained in:
Ross Reicks 2024-07-11 11:34:33 -05:00
parent 95058abb17
commit c4f7701aa1
9 changed files with 11991 additions and 5 deletions

View file

@ -21,6 +21,7 @@ import {SwiftXunitParser} from './parsers/swift-xunit/swift-xunit-parser'
import {normalizeDirPath, normalizeFilePath} from './utils/path-utils'
import {getCheckRunContext} from './utils/github-utils'
import {ApexJsonParser} from './parsers/apex-json/apex-json-parsers'
async function main(): Promise<void> {
try {
@ -243,6 +244,8 @@ class TestReporter {
return new RspecJsonParser(options)
case 'swift-xunit':
return new SwiftXunitParser(options)
case 'apex-json':
return new ApexJsonParser(options)
default:
throw new Error(`Input variable 'reporter' is set to invalid value '${reporter}'`)
}

View file

@ -0,0 +1,10 @@
import {ParseOptions, TestParser} from '../../test-parser'
import {TestRunResult} from '../../test-results'
export class ApexJsonParser implements TestParser {
constructor(readonly options: ParseOptions) {}
async parse(path: string, content: string): Promise<TestRunResult> {
throw new Error('Method not implemented.')
}
}

View file

@ -0,0 +1,92 @@
export interface RootObject {
result: Result
}
export interface Result {
summary: SuiteSummary
tests: Test[]
coverage: SuiteCoverage
}
export interface SuiteCoverage {
coverage?: Coverage[]
records: ApexRecord[]
summary: SuiteCoverageSummary
}
export interface SuiteCoverageSummary {
totalLines: number
coveredLines: number
orgWideCoverage: string
testRunCoverage: string
}
export interface ApexRecord {
ApexTestClass: ApexTestClass
Coverage: RecordCoverage
TestMethodName: string
NumLinesCovered: number
ApexClassOrTrigger: ApexTestClass
NumLinesUncovered: number
}
export interface RecordCoverage {
coveredLines: number[]
uncoveredLines: number[]
}
export interface ApexTestClass {
Id: string
Name: string
}
export interface Coverage {
id: string
name: string
totalLines: number
lines: Lines
totalCovered: number
coveredPercent: number
}
export type Lines = Record<number, number>
export interface Test {
Id: string
QueueItemId: string
StackTrace: null
Message: null
AsyncApexJobId: string
MethodName: string
Outcome: string
ApexClass: ApexClass
RunTime: number
FullName: string
}
export interface ApexClass {
Id: string
Name: string
NamespacePrefix: string
}
export interface SuiteSummary {
failRate: string
failing: number
hostname: string
orgId: string
outcome: string
passRate: string
passing: number
skipped: number
testRunId: string
testStartTime: string
testsRan: number
userId: string
username: string
commandTime: string
testExecutionTime: string
testTotalTime: string
orgWideCoverage: string
testRunCoverage: string
}