@@ -40,6 +40,19 @@ export interface SurefireReport {
40
40
}
41
41
}
42
42
43
+ function trimJunit5StackTrace ( stackTrace : string ) : string {
44
+ if ( ! stackTrace ) {
45
+ return ''
46
+ }
47
+ const lines = stackTrace . split ( '\n' )
48
+ const idxOfJunitLine = lines . findIndex ( ( line ) =>
49
+ line . includes ( 'org.junit.jupiter.engine.execution.MethodInvocation.proceed' )
50
+ )
51
+ return idxOfJunitLine === - 1
52
+ ? stackTrace
53
+ : lines . slice ( 0 , idxOfJunitLine ) . join ( '\n' )
54
+ }
55
+
43
56
export function parseSurefireXml ( filePath : string ) : SurefireReport {
44
57
const xmlContent = readFileSync ( filePath , 'utf-8' )
45
58
const parser = new XMLParser ( {
@@ -93,7 +106,7 @@ export function parseSurefireXml(filePath: string): SurefireReport {
93
106
message : testCase . failure . message || '' ,
94
107
type : testCase . failure . type || '' ,
95
108
description : testCase . failure . _text || '' ,
96
- stackTrace : testCase . failure . _text || ''
109
+ stackTrace : trimJunit5StackTrace ( testCase . failure . _text || '' )
97
110
}
98
111
}
99
112
@@ -103,7 +116,7 @@ export function parseSurefireXml(filePath: string): SurefireReport {
103
116
message : testCase . error . message || '' ,
104
117
type : testCase . error . type || '' ,
105
118
description : testCase . error . _text || '' ,
106
- stackTrace : testCase . error . _text || ''
119
+ stackTrace : trimJunit5StackTrace ( testCase . error . _text || '' )
107
120
}
108
121
}
109
122
0 commit comments