mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Merge branch 'main' into issue-208-java-junit-show-annotations-on-pr-changed-files
This commit is contained in:
commit
6af36d9ecf
4 changed files with 32 additions and 8 deletions
2
__tests__/fixtures/external/java/empty_failures.xml
vendored
Normal file
2
__tests__/fixtures/external/java/empty_failures.xml
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<testsuites name="my_package.test_foo" tests="3" failures="1" errors="0" time="6.79"><testsuite name="my_package.test_foo.launch_tests" tests="3" failures="1" errors="0" skipped="0" time="6.79"><testcase classname="my_package.TestFoo" name="test_normal_case" time="2.172" /><testcase classname="my_package.TestFoo" name="test_other_case" time="4.558"><failure message="Traceback (most recent call last): File "/home/redacted/test_foo.py", line 183, in test_other_case self.assertFalse(True) AssertionError: True is not false " /></testcase><testcase classname="my_package.TestFoo" name="test_yet_another_case" time="0.06" /></testsuite></testsuites>
|
||||||
|
|
@ -72,4 +72,22 @@ describe('java-junit tests', () => {
|
||||||
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
|
||||||
fs.writeFileSync(outputPath, report)
|
fs.writeFileSync(outputPath, report)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('parses empty failures in test results', async () => {
|
||||||
|
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'java', 'empty_failures.xml')
|
||||||
|
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||||
|
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||||
|
|
||||||
|
const trackedFiles: string[] = []
|
||||||
|
const opts: ParseOptions = {
|
||||||
|
parseErrors: true,
|
||||||
|
trackedFiles
|
||||||
|
}
|
||||||
|
|
||||||
|
const parser = new JavaJunitParser(opts)
|
||||||
|
const result = await parser.parse(filePath, fileContent)
|
||||||
|
|
||||||
|
expect(result.result === 'failed')
|
||||||
|
expect(result.failed === 1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
10
dist/index.js
generated
vendored
10
dist/index.js
generated
vendored
|
|
@ -1038,10 +1038,12 @@ class JavaJunitParser {
|
||||||
const details = typeof failure === 'object' ? failure._ : failure;
|
const details = typeof failure === 'object' ? failure._ : failure;
|
||||||
let filePath;
|
let filePath;
|
||||||
let line;
|
let line;
|
||||||
const src = this.exceptionThrowSource(details);
|
if (details != null) {
|
||||||
if (src) {
|
const src = this.exceptionThrowSource(details);
|
||||||
filePath = src.filePath;
|
if (src) {
|
||||||
line = src.line;
|
filePath = src.filePath;
|
||||||
|
line = src.line;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
path: filePath,
|
path: filePath,
|
||||||
|
|
|
||||||
|
|
@ -129,10 +129,12 @@ export class JavaJunitParser implements TestParser {
|
||||||
let filePath
|
let filePath
|
||||||
let line
|
let line
|
||||||
|
|
||||||
const src = this.exceptionThrowSource(details)
|
if (details != null) {
|
||||||
if (src) {
|
const src = this.exceptionThrowSource(details)
|
||||||
filePath = src.filePath
|
if (src) {
|
||||||
line = src.line
|
filePath = src.filePath
|
||||||
|
line = src.line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue