mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-15 22:07:09 +01:00
Merge pull request #582 from OlesGalatsan/bugfix/empty-trx-test-definitions
Fix for empty TRX TestDefinitions
This commit is contained in:
commit
d1bf678c89
4 changed files with 42 additions and 2 deletions
|
|
@ -23,6 +23,22 @@ describe('dotnet-trx tests', () => {
|
|||
expect(result.result).toBe('success')
|
||||
})
|
||||
|
||||
it('produces empty test run result when TestDefinitions is empty', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'dotnet-trx-empty-test-definitions.trx')
|
||||
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
|
||||
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
|
||||
|
||||
const opts: ParseOptions = {
|
||||
parseErrors: true,
|
||||
trackedFiles: []
|
||||
}
|
||||
|
||||
const parser = new DotnetTrxParser(opts)
|
||||
const result = await parser.parse(filePath, fileContent)
|
||||
expect(result.tests).toBe(0)
|
||||
expect(result.result).toBe('success')
|
||||
})
|
||||
|
||||
it('matches report snapshot', async () => {
|
||||
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx')
|
||||
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx.md')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TestRun id="80e4c095-f726-4ab2-9441-416daa162672" name="..." runUser="..." xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
|
||||
<Times creation="2021-02-26T10:36:33.7131022+02:00" queuing="2021-02-26T10:36:33.7131029+02:00" start="2021-02-26T10:36:33.3278956+02:00" finish="2021-02-26T10:36:33.7139830+02:00" />
|
||||
<TestSettings name="default" id="863a1d8b-ee3b-45f9-86ee-1869bc4e889f">
|
||||
<Deployment runDeploymentRoot="..." />
|
||||
</TestSettings>
|
||||
<Results />
|
||||
<TestDefinitions />
|
||||
<TestEntries />
|
||||
<TestLists>
|
||||
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
|
||||
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
|
||||
</TestLists>
|
||||
<ResultSummary outcome="Completed">
|
||||
<Counters total="0" executed="0" passed="0" failed="0" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
|
||||
<RunInfos>
|
||||
<RunInfo computerName="..." outcome="Warning" timestamp="2021-02-26T10:36:33.6676104+02:00">
|
||||
<Text>No test is available in (...). Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.</Text>
|
||||
</RunInfo>
|
||||
</RunInfos>
|
||||
</ResultSummary>
|
||||
</TestRun>
|
||||
3
dist/index.js
generated
vendored
3
dist/index.js
generated
vendored
|
|
@ -937,7 +937,8 @@ class DotnetTrxParser {
|
|||
}
|
||||
}
|
||||
getTestClasses(trx) {
|
||||
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined) {
|
||||
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined ||
|
||||
!trx.TestRun.TestDefinitions.some(td => td.UnitTest && Array.isArray(td.UnitTest))) {
|
||||
return [];
|
||||
}
|
||||
const unitTests = {};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ export class DotnetTrxParser implements TestParser {
|
|||
}
|
||||
|
||||
private getTestClasses(trx: TrxReport): TestClass[] {
|
||||
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined) {
|
||||
if (trx.TestRun.TestDefinitions === undefined || trx.TestRun.Results === undefined ||
|
||||
!trx.TestRun.TestDefinitions.some(td => td.UnitTest && Array.isArray(td.UnitTest))) {
|
||||
return []
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue