fix: update result structure to use 'name' instead of 'suitename' in JUnit output (#6120)

* fix: update result structure to use 'name' instead of 'suitename' in JUnit output
This commit is contained in:
Abhishek S Lal
2025-11-18 12:31:41 +05:30
committed by GitHub
parent e9111c0529
commit 2ac41806a2
6 changed files with 16 additions and 16 deletions

View File

@@ -546,7 +546,7 @@ const handler = async function (argv) {
let nJumps = 0; // count the number of jumps to avoid infinite loops
while (currentRequestIndex < requestItems.length) {
const requestItem = cloneDeep(requestItems[currentRequestIndex]);
const { pathname } = requestItem;
const { name, pathname } = requestItem;
const start = process.hrtime();
const result = await runSingleRequest(
@@ -576,7 +576,8 @@ const handler = async function (argv) {
results.push({
...result,
runtime: process.hrtime(start)[0] + process.hrtime(start)[1] / 1e9,
suitename: pathname.replace('.bru', '')
suitename: pathname.replace('.bru', ''),
name
});
if (reporterSkipAllHeaders) {

View File

@@ -15,7 +15,7 @@ const makeJUnitOutput = async (results, outputPath) => {
const totalTests = assertionTestCount + testCount;
const suite = {
'@name': result.suitename,
'@name': result.name,
'@errors': 0,
'@failures': 0,
'@skipped': 0,

View File

@@ -22,7 +22,7 @@ describe('makeJUnitOutput', () => {
const results = [
{
description: 'description provided',
suitename: 'Tests/Suite A',
name: 'Tests/Suite A',
request: {
method: 'GET',
url: 'https://ima.test'
@@ -47,7 +47,7 @@ describe('makeJUnitOutput', () => {
method: 'GET',
url: 'https://imanother.test'
},
suitename: 'Tests/Suite B',
name: 'Tests/Suite B',
testResults: [
{
lhsExpr: 'res.status',
@@ -98,7 +98,7 @@ describe('makeJUnitOutput', () => {
const results = [
{
description: 'description provided',
suitename: 'Tests/Suite A',
name: 'Tests/Suite A',
request: {
method: 'GET',
url: 'https://ima.test'

View File

@@ -12,7 +12,7 @@ function normalizeJunitReport(xmlContent: string): string {
// Replace execution times with fixed value
.replace(/time="[^"]*"/g, 'time="0.100"')
// Replace file paths with normalized path
.replace(/name="[^"]*\/[^"]*"/g, 'name="/test/path/collection"');
.replace(/classname="[^"]*\/[^"]*"/g, 'classname="/test/path/collection"');
}
test.describe('Collection Run Report Tests', () => {
@@ -35,7 +35,6 @@ test.describe('Collection Run Report Tests', () => {
// Verify report was generated
expect(fs.existsSync(junitOutputPath)).toBe(true);
const junitReportContent = fs.readFileSync(junitOutputPath, 'utf8');
// Snapshot the normalized XML
const normalizedJunitReport = normalizeJunitReport(junitReportContent);
expect(normalizedJunitReport).toMatchSnapshot('cli-junit-report.xml');

View File

@@ -1,12 +1,12 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="/test/path/collection" errors="0" failures="0" skipped="0" tests="4" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Get User Info" errors="0" failures="0" skipped="0" tests="4" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has slideshow property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Slideshow has title" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="1" skipped="0" tests="5" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Get UUID" errors="0" failures="1" skipped="0" tests="5" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 404"/>
</testcase>
@@ -15,12 +15,12 @@
<testcase name="Response has uuid property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="UUID is a string" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="0" skipped="0" tests="3" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Login Request" errors="0" failures="0" skipped="0" tests="3" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has json field" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response json has username" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="1" skipped="0" tests="2" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Logout Request" errors="0" failures="1" skipped="0" tests="2" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will also fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 500"/>
</testcase>

View File

@@ -1,12 +1,12 @@
<?xml version="1.0"?>
<testsuites>
<testsuite name="/test/path/collection" errors="0" failures="0" skipped="0" tests="4" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Get User Info" errors="0" failures="0" skipped="0" tests="4" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has slideshow property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Slideshow has title" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="1" skipped="0" tests="5" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Get UUID" errors="0" failures="1" skipped="0" tests="5" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 404"/>
</testcase>
@@ -15,12 +15,12 @@
<testcase name="Response has uuid property" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="UUID is a string" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="0" skipped="0" tests="3" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Login Request" errors="0" failures="0" skipped="0" tests="3" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response has json field" status="pass" classname="/test/path/collection" time="0.100"/>
<testcase name="Response json has username" status="pass" classname="/test/path/collection" time="0.100"/>
</testsuite>
<testsuite name="/test/path/collection" errors="0" failures="1" skipped="0" tests="2" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testsuite name="Logout Request" errors="0" failures="1" skipped="0" tests="2" timestamp="2024-01-01T00:00:00.000" hostname="test-host" time="0.100">
<testcase name="This test will also fail" status="fail" classname="/test/path/collection" time="0.100">
<failure type="failure" message="expected 200 to equal 500"/>
</testcase>