Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yedidyas committed Jan 14, 2025
1 parent 2db0376 commit 7f713bd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
10 changes: 6 additions & 4 deletions src/parsers/dotnet-trx/dotnet-trx-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ export class DotnetTrxParser implements TestParser {
return undefined;
}

const message = error.Message[0];
const stackTrace = error.StackTrace[0];
const stdOut = test.stdOut || ''; // Use StdOut from Test object
const message = test.error.Message[0];
const stackTrace = test.error.StackTrace[0];
const stdOut = test.stdOut || ''; // Add StdOut

let path;
let line;

Expand All @@ -167,7 +168,8 @@ export class DotnetTrxParser implements TestParser {
path,
line,
message,
details: `${message}\n${stackTrace}\n${stdOut}`,
details: `${message}\n${stackTrace}`,
stdOut, // Include StdOut in TestCaseError
};
}

Expand Down
53 changes: 32 additions & 21 deletions src/report/get-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,45 +230,56 @@ function getSuitesReport(tr: TestRunResult, runIndex: number, options: ReportOpt

function getTestsReport(ts: TestSuiteResult, runIndex: number, suiteIndex: number, options: ReportOptions): string[] {
if (options.listTests === 'failed' && ts.result !== 'failed') {
return []
return [];
}
const groups = ts.groups
const groups = ts.groups;
if (groups.length === 0) {
return []
return [];
}

const sections: string[] = []
const sections: string[] = [];

const tsName = ts.name
const tsSlug = makeSuiteSlug(runIndex, suiteIndex)
const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>`
const icon = getResultIcon(ts.result)
sections.push(`### ${icon}\xa0${tsNameLink}`)
const tsName = ts.name;
const tsSlug = makeSuiteSlug(runIndex, suiteIndex);
const tsNameLink = `<a id="${tsSlug.id}" href="${options.baseUrl + tsSlug.link}">${tsName}</a>`;
const icon = getResultIcon(ts.result);
sections.push(`### ${icon}\xa0${tsNameLink}`);

sections.push('```')
sections.push('```');
for (const grp of groups) {
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) {
const result = getResultIcon(tc.result)
sections.push(`${space}${result} ${tc.name}`)
const result = getResultIcon(tc.result);
sections.push(`${space}${result} ${tc.name}`);
if (tc.error) {
const lines = (tc.error.message ?? getFirstNonEmptyLine(tc.error.details)?.trim())
?.split(/\r?\n/g)
.map(l => '\t' + l)
if (lines) {
sections.push(...lines)
const errorDetails: string[] = [];

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('```')
sections.push('```');

return sections
return sections;
}


function makeRunSlug(runIndex: number): {id: string; link: string} {
// use prefix to avoid slug conflicts after escaping the paths
return slug(`r${runIndex}`)
Expand Down
10 changes: 6 additions & 4 deletions src/test-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ export class TestCaseResult {
export type TestExecutionResult = 'success' | 'skipped' | 'failed' | undefined

export interface TestCaseError {
path?: string
line?: number
message?: string
details: string
path?: string;
line?: number;
message: string;
details: string;
stdOut?: string;
}

0 comments on commit 7f713bd

Please sign in to comment.