Skip to content

Commit 2ac4180

Browse files
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
1 parent e9111c0 commit 2ac4180

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

packages/bruno-cli/src/commands/run.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ const handler = async function (argv) {
546546
let nJumps = 0; // count the number of jumps to avoid infinite loops
547547
while (currentRequestIndex < requestItems.length) {
548548
const requestItem = cloneDeep(requestItems[currentRequestIndex]);
549-
const { pathname } = requestItem;
549+
const { name, pathname } = requestItem;
550550

551551
const start = process.hrtime();
552552
const result = await runSingleRequest(
@@ -576,7 +576,8 @@ const handler = async function (argv) {
576576
results.push({
577577
...result,
578578
runtime: process.hrtime(start)[0] + process.hrtime(start)[1] / 1e9,
579-
suitename: pathname.replace('.bru', '')
579+
suitename: pathname.replace('.bru', ''),
580+
name
580581
});
581582

582583
if (reporterSkipAllHeaders) {

packages/bruno-cli/src/reporters/junit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const makeJUnitOutput = async (results, outputPath) => {
1515
const totalTests = assertionTestCount + testCount;
1616

1717
const suite = {
18-
'@name': result.suitename,
18+
'@name': result.name,
1919
'@errors': 0,
2020
'@failures': 0,
2121
'@skipped': 0,

packages/bruno-cli/tests/reporters/junit.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('makeJUnitOutput', () => {
2222
const results = [
2323
{
2424
description: 'description provided',
25-
suitename: 'Tests/Suite A',
25+
name: 'Tests/Suite A',
2626
request: {
2727
method: 'GET',
2828
url: 'https://ima.test'
@@ -47,7 +47,7 @@ describe('makeJUnitOutput', () => {
4747
method: 'GET',
4848
url: 'https://imanother.test'
4949
},
50-
suitename: 'Tests/Suite B',
50+
name: 'Tests/Suite B',
5151
testResults: [
5252
{
5353
lhsExpr: 'res.status',
@@ -98,7 +98,7 @@ describe('makeJUnitOutput', () => {
9898
const results = [
9999
{
100100
description: 'description provided',
101-
suitename: 'Tests/Suite A',
101+
name: 'Tests/Suite A',
102102
request: {
103103
method: 'GET',
104104
url: 'https://ima.test'

tests/runner/collection-run-report/collection-run-report.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function normalizeJunitReport(xmlContent: string): string {
1212
// Replace execution times with fixed value
1313
.replace(/time="[^"]*"/g, 'time="0.100"')
1414
// Replace file paths with normalized path
15-
.replace(/name="[^"]*\/[^"]*"/g, 'name="/test/path/collection"');
15+
.replace(/classname="[^"]*\/[^"]*"/g, 'classname="/test/path/collection"');
1616
}
1717

1818
test.describe('Collection Run Report Tests', () => {
@@ -35,7 +35,6 @@ test.describe('Collection Run Report Tests', () => {
3535
// Verify report was generated
3636
expect(fs.existsSync(junitOutputPath)).toBe(true);
3737
const junitReportContent = fs.readFileSync(junitOutputPath, 'utf8');
38-
3938
// Snapshot the normalized XML
4039
const normalizedJunitReport = normalizeJunitReport(junitReportContent);
4140
expect(normalizedJunitReport).toMatchSnapshot('cli-junit-report.xml');

tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-darwin.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0"?>
22
<testsuites>
3-
<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">
3+
<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">
44
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
55
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
66
<testcase name="Response has slideshow property" status="pass" classname="/test/path/collection" time="0.100"/>
77
<testcase name="Slideshow has title" status="pass" classname="/test/path/collection" time="0.100"/>
88
</testsuite>
9-
<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">
9+
<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">
1010
<testcase name="This test will fail" status="fail" classname="/test/path/collection" time="0.100">
1111
<failure type="failure" message="expected 200 to equal 404"/>
1212
</testcase>
@@ -15,12 +15,12 @@
1515
<testcase name="Response has uuid property" status="pass" classname="/test/path/collection" time="0.100"/>
1616
<testcase name="UUID is a string" status="pass" classname="/test/path/collection" time="0.100"/>
1717
</testsuite>
18-
<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">
18+
<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">
1919
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
2020
<testcase name="Response has json field" status="pass" classname="/test/path/collection" time="0.100"/>
2121
<testcase name="Response json has username" status="pass" classname="/test/path/collection" time="0.100"/>
2222
</testsuite>
23-
<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">
23+
<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">
2424
<testcase name="This test will also fail" status="fail" classname="/test/path/collection" time="0.100">
2525
<failure type="failure" message="expected 200 to equal 500"/>
2626
</testcase>

tests/runner/collection-run-report/collection-run-report.spec.ts-snapshots/cli-junit-report-default-linux.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0"?>
22
<testsuites>
3-
<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">
3+
<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">
44
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
55
<testcase name="Response is an object" status="pass" classname="/test/path/collection" time="0.100"/>
66
<testcase name="Response has slideshow property" status="pass" classname="/test/path/collection" time="0.100"/>
77
<testcase name="Slideshow has title" status="pass" classname="/test/path/collection" time="0.100"/>
88
</testsuite>
9-
<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">
9+
<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">
1010
<testcase name="This test will fail" status="fail" classname="/test/path/collection" time="0.100">
1111
<failure type="failure" message="expected 200 to equal 404"/>
1212
</testcase>
@@ -15,12 +15,12 @@
1515
<testcase name="Response has uuid property" status="pass" classname="/test/path/collection" time="0.100"/>
1616
<testcase name="UUID is a string" status="pass" classname="/test/path/collection" time="0.100"/>
1717
</testsuite>
18-
<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">
18+
<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">
1919
<testcase name="Status code is 200" status="pass" classname="/test/path/collection" time="0.100"/>
2020
<testcase name="Response has json field" status="pass" classname="/test/path/collection" time="0.100"/>
2121
<testcase name="Response json has username" status="pass" classname="/test/path/collection" time="0.100"/>
2222
</testsuite>
23-
<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">
23+
<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">
2424
<testcase name="This test will also fail" status="fail" classname="/test/path/collection" time="0.100">
2525
<failure type="failure" message="expected 200 to equal 500"/>
2626
</testcase>

0 commit comments

Comments
 (0)