mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 06:34:06 +00:00
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:
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user