This commit is contained in:
yedidyas 2025-01-14 20:56:21 +02:00
parent 2db037664f
commit 7f713bd00e
3 changed files with 44 additions and 29 deletions

View file

@ -151,9 +151,10 @@ export class DotnetTrxParser implements TestParser {
return undefined; return undefined;
} }
const message = error.Message[0]; const message = test.error.Message[0];
const stackTrace = error.StackTrace[0]; const stackTrace = test.error.StackTrace[0];
const stdOut = test.stdOut || ''; // Use StdOut from Test object const stdOut = test.stdOut || ''; // Add StdOut
let path; let path;
let line; let line;
@ -167,7 +168,8 @@ export class DotnetTrxParser implements TestParser {
path, path,
line, line,
message, message,
details: `${message}\n${stackTrace}\n${stdOut}`, details: `${message}\n${stackTrace}`,
stdOut, // Include StdOut in TestCaseError
}; };
} }

View file

@ -230,44 +230,55 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt
function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: number, options: ReportOptions): string[] { function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: number, options: ReportOptions): string[] {
if (options.listTests === 'failed' && ts.result !== 'failed') { if (options.listTests === 'failed' && ts.result !== 'failed') {
return [] return [];
} }
const groups = ts.groups const groups = ts.groups;
if (groups.length === 0) { if (groups.length === 0) {
return [] return [];
} }
const sections: string[] = [] const sections: string[] = [];
const tsName = ts.name const tsName = ts.name;
const tsSlug = makeSuiteSlug(runIndex, suiteIndex) const tsSlug = makeSuiteSlug(runIndex, suiteIndex);
const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>` const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>`;
const icon = getResultIcon(ts.result) const icon = getResultIcon(ts.result);
sections.push(`### ${icon}\xa0${tsNameLink}`) sections.push(`### ${icon}\xa0${tsNameLink}`);
sections.push('```') sections.push('```');
for (const grp of groups) { for (const grp of groups) {
if (grp.name) { if (grp.name) {
sections.push(grp.name) sections.push(grp.name);
} }
const space = grp.name ? ' ' : '' const space = grp.name ? ' ' : '';
for (const tc of grp.tests) { for (const tc of grp.tests) {
const result = getResultIcon(tc.result) const result = getResultIcon(tc.result);
sections.push(`${space}${result} ${tc.name}`) sections.push(`${space}${result} ${tc.name}`);
if (tc.error) { if (tc.error) {
const lines = (tc.error.message ?? getFirstNonEmptyLine(tc.error.details)?.trim()) const errorDetails: string[] = [];
?.split(/\r?\n/g)
.map(l => '\t' + l)
if (lines) {
sections.push(...lines)
}
}
}
}
sections.push('```')
return sections if (tc.error.message) {
errorDetails.push(tc.error.message);
} }
if (tc.error.details) {
errorDetails.push(tc.error.details);
}
if (tc.error.stdOut) {
errorDetails.push(`StdOut:\n${tc.error.stdOut}`); // Include StdOut in report
}
const lines = errorDetails.flatMap((detail) =>
detail.split(/\r?\n/g).map((line) => `\t${line}`)
);
sections.push(...lines);
}
}
}
sections.push('```');
return sections;
}
function makeRunSlug(runIndex: number): {id: string; link: string} { function makeRunSlug(runIndex: number): {id: string; link: string} {
// use prefix to avoid slug conflicts after escaping the paths // use prefix to avoid slug conflicts after escaping the paths

View file

@ -129,8 +129,10 @@ export class TestCaseResult {
export type TestExecutionResult = 'success' | 'skipped' | 'failed' | undefined export type TestExecutionResult = 'success' | 'skipped' | 'failed' | undefined
export interface TestCaseError { export interface TestCaseError {
path?: string path?: string;
line?: number line?: number;
message?: string message: string;
details: string details: string;
stdOut?: string;
} }