mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
Add go-unit test
This commit is contained in:
parent
8079cf8926
commit
e0f4952e74
8 changed files with 184 additions and 32158 deletions
19
__tests__/__outputs__/ginkgo-junit-test-results.md
Normal file
19
__tests__/__outputs__/ginkgo-junit-test-results.md
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|

|
||||||
|
## ❌ <a id="user-content-r0" href="#r0">fixtures/external/go/ginkgo-junit-report.xml</a>
|
||||||
|
**3** tests were completed in **10s** with **2** passed, **1** failed and **0** skipped.
|
||||||
|
|Test suite|Passed|Failed|Skipped|Time|
|
||||||
|
|:---|---:|---:|---:|---:|
|
||||||
|
|[Suite1](#r0s0)|1✔️|||2ms|
|
||||||
|
|[Suite2](#r0s1)|1✔️|1❌||135ms|
|
||||||
|
### ✔️ <a id="user-content-r0s0" href="#r0s0">Suite1</a>
|
||||||
|
```
|
||||||
|
Suite1
|
||||||
|
✔️ [It] Should succeed
|
||||||
|
```
|
||||||
|
### ❌ <a id="user-content-r0s1" href="#r0s1">Suite2</a>
|
||||||
|
```
|
||||||
|
Suite2
|
||||||
|
✔️ [It] Should succeed
|
||||||
|
❌ [It] Should succeed, but errors
|
||||||
|
/package2/a_test.go:52
|
||||||
|
```
|
||||||
22
__tests__/__outputs__/go-junit-report-test-results.md
Normal file
22
__tests__/__outputs__/go-junit-report-test-results.md
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|

|
||||||
|
## ❌ <a id="user-content-r0" href="#r0">fixtures/external/go/go-junit-report.xml</a>
|
||||||
|
**5** tests were completed in **NaNms** with **2** passed, **2** failed and **1** skipped.
|
||||||
|
|Test suite|Passed|Failed|Skipped|Time|
|
||||||
|
|:---|---:|---:|---:|---:|
|
||||||
|
|[github.com/company/package1](#r0s0)||||0ms|
|
||||||
|
|[github.com/company/package2](#r0s1)|1✔️|||482ms|
|
||||||
|
|[github.com/company/package3](#r0s2)|1✔️|2❌|1✖️|835ms|
|
||||||
|
### ✔️ <a id="user-content-r0s1" href="#r0s1">github.com/company/package2</a>
|
||||||
|
```
|
||||||
|
github.com/company/package2
|
||||||
|
✔️ TestPackage2
|
||||||
|
```
|
||||||
|
### ❌ <a id="user-content-r0s2" href="#r0s2">github.com/company/package3</a>
|
||||||
|
```
|
||||||
|
github.com/company/package3
|
||||||
|
❌ TestPackage3-1
|
||||||
|
Just error here
|
||||||
|
✔️ TestPackage3-2
|
||||||
|
✖️ TestPackage3-3
|
||||||
|
❌ TestPackage3-4
|
||||||
|
```
|
||||||
File diff suppressed because it is too large
Load diff
52
__tests__/fixtures/external/go/ginkgo-junit-report.xml
vendored
Normal file
52
__tests__/fixtures/external/go/ginkgo-junit-report.xml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuites tests="4" disabled="0" errors="0" failures="2" time="9.568500872999998">
|
||||||
|
<testsuite name="Suite1" package="/package1" tests="1" disabled="0" skipped="0" errors="0" failures="0" time="0.001759667" timestamp="2022-10-18T15:48:32">
|
||||||
|
<properties>
|
||||||
|
<property name="SuiteSucceeded" value="true"></property>
|
||||||
|
<property name="SuiteHasProgrammaticFocus" value="false"></property>
|
||||||
|
<property name="SpecialSuiteFailureReason" value=""></property>
|
||||||
|
<property name="SuiteLabels" value="[]"></property>
|
||||||
|
<property name="RandomSeed" value="1666126101"></property>
|
||||||
|
<property name="RandomizeAllSpecs" value="false"></property>
|
||||||
|
<property name="LabelFilter" value=""></property>
|
||||||
|
<property name="FocusStrings" value=""></property>
|
||||||
|
<property name="SkipStrings" value=""></property>
|
||||||
|
<property name="FocusFiles" value=""></property>
|
||||||
|
<property name="SkipFiles" value=""></property>
|
||||||
|
<property name="FailOnPending" value="false"></property>
|
||||||
|
<property name="FailFast" value="false"></property>
|
||||||
|
<property name="FlakeAttempts" value="0"></property>
|
||||||
|
<property name="EmitSpecProgress" value="false"></property>
|
||||||
|
<property name="DryRun" value="false"></property>
|
||||||
|
<property name="ParallelTotal" value="1"></property>
|
||||||
|
<property name="OutputInterceptorMode" value=""></property>
|
||||||
|
</properties>
|
||||||
|
<testcase name="[It] Should succeed" classname="Suite1" status="passed" time="0.000455833"></testcase>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="Suite2" package="/package2" tests="3" disabled="0" skipped="0" errors="0" failures="2" time="0.135371083" timestamp="2022-10-18T15:48:32">
|
||||||
|
<properties>
|
||||||
|
<property name="SuiteSucceeded" value="true"></property>
|
||||||
|
<property name="SuiteHasProgrammaticFocus" value="false"></property>
|
||||||
|
<property name="SpecialSuiteFailureReason" value=""></property>
|
||||||
|
<property name="SuiteLabels" value="[]"></property>
|
||||||
|
<property name="RandomSeed" value="1666126101"></property>
|
||||||
|
<property name="RandomizeAllSpecs" value="false"></property>
|
||||||
|
<property name="LabelFilter" value=""></property>
|
||||||
|
<property name="FocusStrings" value=""></property>
|
||||||
|
<property name="SkipStrings" value=""></property>
|
||||||
|
<property name="FocusFiles" value=""></property>
|
||||||
|
<property name="SkipFiles" value=""></property>
|
||||||
|
<property name="FailOnPending" value="false"></property>
|
||||||
|
<property name="FailFast" value="false"></property>
|
||||||
|
<property name="FlakeAttempts" value="0"></property>
|
||||||
|
<property name="EmitSpecProgress" value="false"></property>
|
||||||
|
<property name="DryRun" value="false"></property>
|
||||||
|
<property name="ParallelTotal" value="1"></property>
|
||||||
|
<property name="OutputInterceptorMode" value=""></property>
|
||||||
|
</properties>
|
||||||
|
<testcase name="[It] Should succeed" classname="Suite2" status="passed" time="0.10459475"></testcase>
|
||||||
|
<testcase name="[It] Should succeed, but errors" classname="Suite2" status="failed" time="0.000523208">
|
||||||
|
<failure message="Expected success, but got an error:
 <*errors.withStack | 0x1400000ec30>: {
 error: <*errors.withMessage | 0x1400007e7c0>{
 cause: <*errors.fundamental | 0x14000202c60>{
 msg: "[invalid label",
 stack: [0x1056103f5, 0x104bb628c, 0x104bb61c8, 0x104ba84d8, 0x104bda0b4],
 },
 msg: "outlier",
 },
 stack: [0x10560628c, 0x10560545c, 0x10560f968, 0x1055e9c1c, 0x104bda0b4],
 }
 invalid label" type="failed">/package2/a_test.go:52</failure>
|
||||||
|
</testcase>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
21
__tests__/fixtures/external/go/go-junit-report.xml
vendored
Normal file
21
__tests__/fixtures/external/go/go-junit-report.xml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuites tests="5" failures="2" skipped="1">
|
||||||
|
<testsuite name="github.com/company/package1" tests="0" failures="0" errors="0" id="0" hostname="MBP.local" time="0.000" timestamp="2022-10-13T16:53:32-05:00"></testsuite>
|
||||||
|
<testsuite name="github.com/company/package2" tests="1" failures="0" errors="0" id="8" hostname="MBP.local" time="0.482" timestamp="2022-10-13T16:53:32-05:00">
|
||||||
|
<testcase name="TestPackage2" classname="github.com/company/package2" time="0.000"></testcase>
|
||||||
|
</testsuite>
|
||||||
|
<testsuite name="github.com/company/package3" tests="1" failures="1" errors="0" id="10" hostname="MBP.local" time="0.835" timestamp="2022-10-13T16:53:32-05:00">
|
||||||
|
<testcase name="TestPackage3-1" classname="github.com/company/package3" time="0.000">
|
||||||
|
<failure message="Failed"><![CDATA[Just error here]]></failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestPackage3-2" classname="github.com/company/package3" time="0.160">
|
||||||
|
<system-out><![CDATA[Just system.out here]]></system-out>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestPackage3-3" classname="github.com/company/package3" time="0.000">
|
||||||
|
<skipped message="Skipped"><![CDATA[skipped here]]></skipped>
|
||||||
|
</testcase>
|
||||||
|
<testcase name="TestPackage3-4" classname="github.com/company/package3" time="0.000">
|
||||||
|
<failure message="Failed"></failure>
|
||||||
|
</testcase>
|
||||||
|
</testsuite>
|
||||||
|
</testsuites>
|
||||||
|
|
@ -6,7 +6,7 @@ import {ParseOptions} from '../src/test-parser'
|
||||||
import {getReport} from '../src/report/get-report'
|
import {getReport} from '../src/report/get-report'
|
||||||
import {normalizeFilePath} from '../src/utils/path-utils'
|
import {normalizeFilePath} from '../src/utils/path-utils'
|
||||||
|
|
||||||
describe('jest-junit tests', () => {
|
describe('go-junit tests', () => {
|
||||||
it('produces empty test run result when there are no test cases', async () => {
|
it('produces empty test run result when there are no test cases', async () => {
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit.xml')
|
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'jest-junit.xml')
|
||||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||||
|
|
@ -23,9 +23,9 @@ describe('jest-junit tests', () => {
|
||||||
expect(result.result).toBe('success')
|
expect(result.result).toBe('success')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('report from ./reports/jest test results matches snapshot', async () => {
|
it('report from ./external/go-junit-report test results matches snapshot', async () => {
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'jest-junit.xml')
|
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'go', 'go-junit-report.xml')
|
||||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-junit.md')
|
const outputPath = path.join(__dirname, '__outputs__', 'go-junit-report-test-results.md')
|
||||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||||
|
|
||||||
|
|
@ -44,18 +44,16 @@ describe('jest-junit tests', () => {
|
||||||
fs.writeFileSync(outputPath, report)
|
fs.writeFileSync(outputPath, report)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('report from facebook/jest test results matches snapshot', async () => {
|
it('report from ./external/ginkgo test results matches snapshot', async () => {
|
||||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'jest', 'jest-test-results.xml')
|
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'go', 'ginkgo-junit-report.xml')
|
||||||
const trackedFilesPath = path.join(__dirname, 'fixtures', 'external', 'jest', 'files.txt')
|
const outputPath = path.join(__dirname, '__outputs__', 'ginkgo-junit-test-results.md')
|
||||||
const outputPath = path.join(__dirname, '__outputs__', 'jest-test-results.md')
|
|
||||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||||
|
|
||||||
const trackedFiles = fs.readFileSync(trackedFilesPath, {encoding: 'utf8'}).split(/\n\r?/g)
|
|
||||||
const opts: ParseOptions = {
|
const opts: ParseOptions = {
|
||||||
parseErrors: true,
|
parseErrors: true,
|
||||||
trackedFiles
|
trackedFiles: ['__tests__/main.test.js', '__tests__/second.test.js', 'lib/main.js']
|
||||||
//workDir: '/home/dorny/dorny/jest/'
|
//workDir: 'C:/Users/Michal/Workspace/dorny/test-check/reports/jest/'
|
||||||
}
|
}
|
||||||
|
|
||||||
const parser = new GoJunitParser(opts)
|
const parser = new GoJunitParser(opts)
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export class GoJunitParser implements TestParser {
|
||||||
private getGroups(suite: TestSuite): TestGroupResult[] {
|
private getGroups(suite: TestSuite): TestGroupResult[] {
|
||||||
const groups: {describe: string; tests: TestCase[]}[] = []
|
const groups: {describe: string; tests: TestCase[]}[] = []
|
||||||
const returnEmpytGroups: TestGroupResult[] = [];
|
const returnEmpytGroups: TestGroupResult[] = [];
|
||||||
if (suite.testcase.length === 0) return returnEmpytGroups;
|
if (!suite.testcase?.length) return returnEmpytGroups;
|
||||||
for (const tc of suite.testcase) {
|
for (const tc of suite.testcase) {
|
||||||
let grp = groups.find(g => g.describe === tc.$.classname)
|
let grp = groups.find(g => g.describe === tc.$.classname)
|
||||||
if (grp === undefined) {
|
if (grp === undefined) {
|
||||||
|
|
@ -83,7 +83,8 @@ export class GoJunitParser implements TestParser {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const details = tc.failure[0]
|
const failure = tc.failure?.[0]
|
||||||
|
const details = (typeof failure === 'object' ? failure._ : failure) || ""
|
||||||
let path
|
let path
|
||||||
let line
|
let line
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ export interface TestCase {
|
||||||
name: string
|
name: string
|
||||||
time: string
|
time: string
|
||||||
}
|
}
|
||||||
failure?: string[]
|
failure?: string[] | Failure[]
|
||||||
|
error?: string[] | Failure[]
|
||||||
skipped?: string[]
|
skipped?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Failure {
|
||||||
|
_: string
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue