Skip to content

Commit 3156f85

Browse files
AlexCannonballdevholic22
authored andcommitted
test_runner: remove failure attribute from JUnit reporter
This commit aligns the Node.js test runner's JUnit XML output with the official JUnit specification by removing the non-standard failure attribute from elements. Signed-off-by: Aliaksandr <42497203+AlexCannonball@users.noreply.github.com> Co-authored-by: devholic22 <hyunjoon.tech@gmail.com> PR-URL: #66072 Fixes: #59593 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 9a8fe74 commit 3156f85

3 files changed

Lines changed: 28 additions & 29 deletions

File tree

‎lib/internal/test_runner/reporter/junit.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ module.exports = async function* junitReporter(source) {
149149
children: [inspectWithNoCustomRetry(error, inspectOptions)],
150150
});
151151
currentTest.failures = 1;
152-
currentTest.attrs.failure = error?.message ?? '';
153152
}
154153
}
155154
break;

‎test/fixtures/test-runner/output/junit_empty_diagnostic.snapshot‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<testsuites>
3-
<testcase name="failing" time="*" classname="test" file="*" failure="error">
3+
<testcase name="failing" time="*" classname="test" file="*">
44
<failure type="testCodeFailure" message="error">
55
[Error [ERR_TEST_FAILURE]: error] {
66
code: 'ERR_TEST_FAILURE',

‎test/fixtures/test-runner/output/junit_reporter.snapshot‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<testcase name="sync pass todo with message" time="*" classname="test" file="*">
1717
<skipped type="todo" message="this is a passing todo"/>
1818
</testcase>
19-
<testcase name="sync fail todo" time="*" classname="test" file="*" failure="thrown from sync fail todo">
19+
<testcase name="sync fail todo" time="*" classname="test" file="*">
2020
<skipped type="todo" message="true"/>
2121
<failure type="testCodeFailure" message="thrown from sync fail todo">
2222
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo] {
@@ -28,7 +28,7 @@
2828
}
2929
</failure>
3030
</testcase>
31-
<testcase name="sync fail todo with message" time="*" classname="test" file="*" failure="thrown from sync fail todo with message">
31+
<testcase name="sync fail todo with message" time="*" classname="test" file="*">
3232
<skipped type="todo" message="this is a failing todo"/>
3333
<failure type="testCodeFailure" message="thrown from sync fail todo with message">
3434
[Error [ERR_TEST_FAILURE]: thrown from sync fail todo with message] {
@@ -48,7 +48,7 @@
4848
</testcase>
4949
<testcase name="sync pass" time="*" classname="test" file="*"/>
5050
<!-- this test should pass -->
51-
<testcase name="sync throw fail" time="*" classname="test" file="*" failure="thrown from sync throw fail">
51+
<testcase name="sync throw fail" time="*" classname="test" file="*">
5252
<failure type="testCodeFailure" message="thrown from sync throw fail">
5353
[Error [ERR_TEST_FAILURE]: thrown from sync throw fail] {
5454
code: 'ERR_TEST_FAILURE',
@@ -63,7 +63,7 @@
6363
<skipped type="skipped" message="true"/>
6464
</testcase>
6565
<testcase name="async pass" time="*" classname="test" file="*"/>
66-
<testcase name="async throw fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
66+
<testcase name="async throw fail" time="*" classname="test" file="*">
6767
<failure type="testCodeFailure" message="thrown from async throw fail">
6868
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
6969
code: 'ERR_TEST_FAILURE',
@@ -74,7 +74,7 @@
7474
}
7575
</failure>
7676
</testcase>
77-
<testcase name="async skip fail" time="*" classname="test" file="*" failure="thrown from async throw fail">
77+
<testcase name="async skip fail" time="*" classname="test" file="*">
7878
<skipped type="skipped" message="true"/>
7979
<failure type="testCodeFailure" message="thrown from async throw fail">
8080
[Error [ERR_TEST_FAILURE]: thrown from async throw fail] {
@@ -86,7 +86,7 @@
8686
}
8787
</failure>
8888
</testcase>
89-
<testcase name="async assertion fail" time="*" classname="test" file="*" failure="Expected values to be strictly equal:&#10;&#10;true !== false&#10;">
89+
<testcase name="async assertion fail" time="*" classname="test" file="*">
9090
<failure type="testCodeFailure" message="Expected values to be strictly equal:&#10;&#10;true !== false">
9191
[Error [ERR_TEST_FAILURE]: Expected values to be strictly equal:
9292

@@ -112,7 +112,7 @@ true !== false
112112
</failure>
113113
</testcase>
114114
<testcase name="resolve pass" time="*" classname="test" file="*"/>
115-
<testcase name="reject fail" time="*" classname="test" file="*" failure="rejected from reject fail">
115+
<testcase name="reject fail" time="*" classname="test" file="*">
116116
<failure type="testCodeFailure" message="rejected from reject fail">
117117
[Error [ERR_TEST_FAILURE]: rejected from reject fail] {
118118
code: 'ERR_TEST_FAILURE',
@@ -129,7 +129,7 @@ true !== false
129129
<testcase name="immediate reject - passes but warns" time="*" classname="test" file="*"/>
130130
<testcase name="immediate resolve pass" time="*" classname="test" file="*"/>
131131
<testsuite name="subtest sync throw fail" time="*" disabled="0" errors="0" tests="1" failures="1" skipped="0" timestamp="*" hostname="HOSTNAME">
132-
<testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*" failure="thrown from subtest sync throw fail">
132+
<testcase name="+sync throw fail" time="*" classname="subtest sync throw fail" file="*">
133133
<failure type="testCodeFailure" message="thrown from subtest sync throw fail">
134134
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
135135
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:125:11) {
@@ -145,7 +145,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
145145
</testcase>
146146
<!-- this subtest should make its parent test fail -->
147147
</testsuite>
148-
<testcase name="sync throw non-error fail" time="*" classname="test" file="*" failure="Symbol(thrown symbol from sync throw non-error fail)">
148+
<testcase name="sync throw non-error fail" time="*" classname="test" file="*">
149149
<failure type="testCodeFailure" message="Symbol(thrown symbol from sync throw non-error fail)">
150150
[Error [ERR_TEST_FAILURE]: Symbol(thrown symbol from sync throw non-error fail)] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: Symbol(thrown symbol from sync throw non-error fail) }
151151
</failure>
@@ -169,7 +169,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
169169
<testcase name="sync skip option with message" time="*" classname="test" file="*">
170170
<skipped type="skipped" message="this is skipped"/>
171171
</testcase>
172-
<testcase name="sync skip option is false fail" time="*" classname="test" file="*" failure="this should be executed">
172+
<testcase name="sync skip option is false fail" time="*" classname="test" file="*">
173173
<failure type="testCodeFailure" message="this should be executed">
174174
[Error [ERR_TEST_FAILURE]: this should be executed] {
175175
code: 'ERR_TEST_FAILURE',
@@ -195,7 +195,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
195195
<skipped type="skipped" message="true"/>
196196
</testcase>
197197
<testcase name="callback pass" time="*" classname="test" file="*"/>
198-
<testcase name="callback fail" time="*" classname="test" file="*" failure="callback failure">
198+
<testcase name="callback fail" time="*" classname="test" file="*">
199199
<failure type="testCodeFailure" message="callback failure">
200200
[Error [ERR_TEST_FAILURE]: callback failure] {
201201
code: 'ERR_TEST_FAILURE',
@@ -209,12 +209,12 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
209209
<testcase name="sync t is this in test" time="*" classname="test" file="*"/>
210210
<testcase name="async t is this in test" time="*" classname="test" file="*"/>
211211
<testcase name="callback t is this in test" time="*" classname="test" file="*"/>
212-
<testcase name="callback also returns a Promise" time="*" classname="test" file="*" failure="passed a callback but also returned a Promise">
212+
<testcase name="callback also returns a Promise" time="*" classname="test" file="*">
213213
<failure type="callbackAndPromisePresent" message="passed a callback but also returned a Promise">
214214
[Error [ERR_TEST_FAILURE]: passed a callback but also returned a Promise] { code: 'ERR_TEST_FAILURE', failureType: 'callbackAndPromisePresent', cause: 'passed a callback but also returned a Promise' }
215215
</failure>
216216
</testcase>
217-
<testcase name="callback throw" time="*" classname="test" file="*" failure="thrown from callback throw">
217+
<testcase name="callback throw" time="*" classname="test" file="*">
218218
<failure type="testCodeFailure" message="thrown from callback throw">
219219
[Error [ERR_TEST_FAILURE]: thrown from callback throw] {
220220
code: 'ERR_TEST_FAILURE',
@@ -225,7 +225,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fail
225225
}
226226
</failure>
227227
</testcase>
228-
<testcase name="callback called twice" time="*" classname="test" file="*" failure="callback invoked multiple times">
228+
<testcase name="callback called twice" time="*" classname="test" file="*">
229229
<failure type="multipleCallbackInvocations" message="callback invoked multiple times">
230230
Error [ERR_TEST_FAILURE]: callback invoked multiple times
231231
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:272:3) {
@@ -236,7 +236,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
236236
</failure>
237237
</testcase>
238238
<testcase name="callback called twice in different ticks" time="*" classname="test" file="*"/>
239-
<testcase name="callback called twice in future tick" time="*" classname="test" file="*" failure="callback invoked multiple times">
239+
<testcase name="callback called twice in future tick" time="*" classname="test" file="*">
240240
<failure type="uncaughtException" message="callback invoked multiple times">
241241
Error [ERR_TEST_FAILURE]: callback invoked multiple times
242242
at <node-internal-frames> {
@@ -251,7 +251,7 @@ Error [ERR_TEST_FAILURE]: callback invoked multiple times
251251
}
252252
</failure>
253253
</testcase>
254-
<testcase name="callback async throw" time="*" classname="test" file="*" failure="thrown from callback async throw">
254+
<testcase name="callback async throw" time="*" classname="test" file="*">
255255
<failure type="uncaughtException" message="thrown from callback async throw">
256256
Error [ERR_TEST_FAILURE]: thrown from callback async throw
257257
at <node-internal-frames> {
@@ -269,12 +269,12 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
269269
<testcase name="running subtest 3" time="*" classname="only is set on subtests but not in only mode" file="*"/>
270270
<testcase name="running subtest 4" time="*" classname="only is set on subtests but not in only mode" file="*"/>
271271
</testsuite>
272-
<testcase name="custom inspect symbol fail" time="*" classname="test" file="*" failure="customized">
272+
<testcase name="custom inspect symbol fail" time="*" classname="test" file="*">
273273
<failure type="testCodeFailure" message="customized">
274274
[Error [ERR_TEST_FAILURE]: customized] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: customized }
275275
</failure>
276276
</testcase>
277-
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*" failure="{&#10; foo: 1,&#10; Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]&#10;}">
277+
<testcase name="custom inspect symbol that throws fail" time="*" classname="test" file="*">
278278
<failure type="testCodeFailure" message="{&#10; foo: 1,&#10; Symbol(nodejs.util.inspect.custom): [Function: [nodejs.util.inspect.custom]]&#10;}">
279279
[Error [ERR_TEST_FAILURE]: {
280280
foo: 1,
@@ -287,7 +287,7 @@ Error [ERR_TEST_FAILURE]: thrown from callback async throw
287287
</failure>
288288
</testcase>
289289
<testsuite name="subtest sync throw fails" time="*" disabled="0" errors="0" tests="2" failures="2" skipped="0" timestamp="*" hostname="HOSTNAME">
290-
<testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at first">
290+
<testcase name="sync throw fails at first" time="*" classname="subtest sync throw fails" file="*">
291291
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at first">
292292
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
293293
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:334:11) {
@@ -301,7 +301,7 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at first
301301
}
302302
</failure>
303303
</testcase>
304-
<testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*" failure="thrown from subtest sync throw fails at second">
304+
<testcase name="sync throw fails at second" time="*" classname="subtest sync throw fails" file="*">
305305
<failure type="testCodeFailure" message="thrown from subtest sync throw fails at second">
306306
Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
307307
at TestContext.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:337:11) {
@@ -316,25 +316,25 @@ Error [ERR_TEST_FAILURE]: thrown from subtest sync throw fails at second
316316
</failure>
317317
</testcase>
318318
</testsuite>
319-
<testcase name="timed out async test" time="*" classname="test" file="*" failure="test timed out after 5ms">
319+
<testcase name="timed out async test" time="*" classname="test" file="*">
320320
<failure type="testTimeoutFailure" message="test timed out after 5ms">
321321
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
322322
</failure>
323323
</testcase>
324-
<testcase name="timed out callback test" time="*" classname="test" file="*" failure="test timed out after 5ms">
324+
<testcase name="timed out callback test" time="*" classname="test" file="*">
325325
<failure type="testTimeoutFailure" message="test timed out after 5ms">
326326
[Error [ERR_TEST_FAILURE]: test timed out after 5ms] { code: 'ERR_TEST_FAILURE', failureType: 'testTimeoutFailure', cause: 'test timed out after 5ms' }
327327
</failure>
328328
</testcase>
329329
<testcase name="large timeout async test is ok" time="*" classname="test" file="*"/>
330330
<testcase name="large timeout callback test is ok" time="*" classname="test" file="*"/>
331331
<testcase name="successful thenable" time="*" classname="test" file="*"/>
332-
<testcase name="rejected thenable" time="*" classname="test" file="*" failure="custom error">
332+
<testcase name="rejected thenable" time="*" classname="test" file="*">
333333
<failure type="testCodeFailure" message="custom error">
334334
[Error [ERR_TEST_FAILURE]: custom error] { code: 'ERR_TEST_FAILURE', failureType: 'testCodeFailure', cause: 'custom error' }
335335
</failure>
336336
</testcase>
337-
<testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*" failure="foo">
337+
<testcase name="unfinished test with uncaughtException" time="*" classname="test" file="*">
338338
<failure type="uncaughtException" message="foo">
339339
Error [ERR_TEST_FAILURE]: foo
340340
at <node-internal-frames> {
@@ -346,7 +346,7 @@ Error [ERR_TEST_FAILURE]: foo
346346
}
347347
</failure>
348348
</testcase>
349-
<testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*" failure="bar">
349+
<testcase name="unfinished test with unhandledRejection" time="*" classname="test" file="*">
350350
<failure type="unhandledRejection" message="bar">
351351
Error [ERR_TEST_FAILURE]: bar
352352
at <node-internal-frames> {
@@ -358,7 +358,7 @@ Error [ERR_TEST_FAILURE]: bar
358358
}
359359
</failure>
360360
</testcase>
361-
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*" failure="Expected values to be loosely deep-equal:&#10;&#10;{&#10; bar: 1,&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; foo: 1&#10;}&#10;&#10;should loosely deep-equal&#10;&#10;{&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; circular: &lt;ref *1> {&#10; bar: 2,&#10; c: [Circular *1]&#10; }&#10;}">
361+
<testcase name="assertion errors display actual and expected properly" time="*" classname="test" file="*">
362362
<failure type="testCodeFailure" message="Expected values to be loosely deep-equal:&#10;&#10;{&#10; bar: 1,&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; foo: 1&#10;}&#10;&#10;should loosely deep-equal&#10;&#10;{&#10; baz: {&#10; date: 1970-01-01T00:00:00.000Z,&#10; null: null,&#10; number: 1,&#10; string: 'Hello',&#10; undefined: undefined&#10; },&#10; boo: [&#10; 1&#10; ],&#10; circular: &lt;ref *1> {&#10; bar: 2,&#10; c: [Circular *1]&#10; }&#10;}">
363363
[Error [ERR_TEST_FAILURE]: Expected values to be loosely deep-equal:
364364

@@ -443,7 +443,7 @@ should loosely deep-equal
443443
}
444444
</failure>
445445
</testcase>
446-
<testcase name="invalid subtest fail" time="*" classname="test" file="*" failure="test could not be started because its parent finished">
446+
<testcase name="invalid subtest fail" time="*" classname="test" file="*">
447447
<failure type="parentAlreadyFinished" message="test could not be started because its parent finished">
448448
Error [ERR_TEST_FAILURE]: test could not be started because its parent finished
449449
at Immediate.&lt;anonymous> (<project-root>/test/fixtures/test-runner/output/output.js:197:7) {

0 commit comments

Comments
 (0)