mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-17 06:47:09 +01:00
feat: support pytest trace back parsing
This commit is contained in:
parent
a007309f5d
commit
7442569c25
5 changed files with 163 additions and 28 deletions
12
__tests__/fixtures/external/pytest/report-tb-short.xml
vendored
Normal file
12
__tests__/fixtures/external/pytest/report-tb-short.xml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<testsuites>
|
||||
<testsuite name="pytest" errors="0" failures="1" skipped="0" tests="1" time="0.316"
|
||||
timestamp="2023-03-10T11:26:51.659606" hostname="c29b94e3532a">
|
||||
<testcase classname="product_changes.tests.first_test.MyTestCase" name="test_something" time="0.075">
|
||||
<failure message="assert False">mnt/extra-addons/product_changes/tests/first_test.py:6: in test_something
|
||||
assert False
|
||||
E assert False
|
||||
</failure>
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
|
@ -21,4 +21,24 @@ describe('pytest-junit tests', () => {
|
|||
expect(result.tests).toBe(1)
|
||||
expect(result.result).toBe('success')
|
||||
})
|
||||
|
||||
it('test failure with trace back', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'external', 'pytest', 'report-tb-short.xml')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles: []
|
||||
}
|
||||
|
||||
const parser = new PytestJunitParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result.tests).toBe(1)
|
||||
expect(result.result).toBe('failed')
|
||||
expect(result.failedSuites[0].failedGroups[0].failedTests[0].error).toMatchObject({
|
||||
line: 6,
|
||||
message: 'assert False'
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue