@@ -17,6 +17,8 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
1717 private triggeredTestsMapping : Map < string , TestItem > = new Map ( ) ;
1818 private projectName : string ;
1919 private incompleteTestSuite : ITestInfo [ ] = [ ] ;
20+ private enqueuedTests : Set < TestItem > = new Set ( ) ;
21+ private suiteItems : Set < TestItem > = new Set ( ) ;
2022
2123 // tests may be run concurrently, so each item's current state needs to be remembered
2224 private currentStates : Map < TestItem , CurrentItemState > = new Map ( ) ;
@@ -67,27 +69,30 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
6769 if ( data . startsWith ( MessageId . TestTree ) ) {
6870 this . enlistToTestMapping ( data . substring ( MessageId . TestTree . length ) . trim ( ) ) ;
6971 } else if ( data . startsWith ( MessageId . TestStart ) ) {
70- const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestStart . length ) ) ;
71- if ( ! item ) {
72+ const testInfo : ITestInfo | undefined = this . getTestInfo ( data . substr ( MessageId . TestStart . length ) ) ;
73+ if ( ! testInfo ?. testItem ) {
7274 return ;
7375 }
74- this . initializeParentState ( item , this . triggeredTestsMapping ) ;
76+ const item : TestItem = testInfo . testItem ;
7577 this . setCurrentState ( item , TestResultState . Running , 0 ) ;
7678 this . setDurationAtStart ( this . getCurrentState ( item ) ) ;
77- setTestState ( this . testContext . testRun , item , this . getCurrentState ( item ) . resultState ) ;
78- this . updateParentOnChildStart ( item ) ;
79+ if ( ! testInfo . isSuite ) {
80+ setTestState ( this . testContext . testRun , item , this . getCurrentState ( item ) . resultState ) ;
81+ }
7982 } else if ( data . startsWith ( MessageId . TestEnd ) ) {
80- const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestEnd . length ) ) ;
81- if ( ! item ) {
83+ const testInfo : ITestInfo | undefined = this . getTestInfo ( data . substr ( MessageId . TestEnd . length ) ) ;
84+ if ( ! testInfo ?. testItem ) {
8285 return ;
8386 }
87+ const item : TestItem = testInfo . testItem ;
8488 const currentState : CurrentItemState = this . getCurrentState ( item ) ;
8589 this . calcDurationAtEnd ( currentState ) ;
8690 this . determineResultStateAtEnd ( data , currentState ) ;
87- setTestState ( this . testContext . testRun , item , currentState . resultState , undefined , currentState . duration ) ;
88- const itemData : ITestItemData | undefined = dataCache . get ( item ) ;
89- if ( itemData ?. testLevel === TestLevel . Method ) {
90- this . updateParentOnChildComplete ( item , currentState . resultState ) ;
91+ const shouldReportSuite : boolean = currentState . resultState === TestResultState . Failed ||
92+ currentState . resultState === TestResultState . Errored ||
93+ ( currentState . resultState === TestResultState . Skipped && testInfo . testCount === 0 ) ;
94+ if ( ! testInfo . isSuite || shouldReportSuite ) {
95+ setTestState ( this . testContext . testRun , item , currentState . resultState , undefined , currentState . duration ) ;
9196 }
9297 } else if ( data . startsWith ( MessageId . TestFailed ) ) {
9398 const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestFailed . length ) ) ;
@@ -121,14 +126,18 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
121126 return ;
122127 }
123128 const currentResultState : TestResultState = this . getCurrentState ( this . tracingItem ) . resultState ;
124- if ( this . assertionFailure ) {
125- this . tryAppendMessage ( this . tracingItem , this . assertionFailure , currentResultState ) ;
126- }
127- if ( this . traces ?. value ) {
128- this . tryAppendMessage ( this . tracingItem , new TestMessage ( this . traces ) , currentResultState ) ;
129- }
130- if ( currentResultState === TestResultState . Errored ) {
131- setTestState ( this . testContext . testRun , this . tracingItem , currentResultState ) ;
129+ const isSkippedSuite : boolean = currentResultState === TestResultState . Skipped &&
130+ this . suiteItems . has ( this . tracingItem ) ;
131+ if ( ! isSkippedSuite ) {
132+ if ( this . assertionFailure ) {
133+ this . tryAppendMessage ( this . tracingItem , this . assertionFailure , currentResultState ) ;
134+ }
135+ if ( this . traces ?. value ) {
136+ this . tryAppendMessage ( this . tracingItem , new TestMessage ( this . traces ) , currentResultState ) ;
137+ }
138+ if ( currentResultState === TestResultState . Errored ) {
139+ setTestState ( this . testContext . testRun , this . tracingItem , currentResultState ) ;
140+ }
132141 }
133142 this . recordingType = RecordingType . None ;
134143 } else if ( data . startsWith ( MessageId . ExpectStart ) ) {
@@ -192,8 +201,12 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
192201 }
193202
194203 protected getTestItem ( message : string ) : TestItem | undefined {
204+ return this . getTestInfo ( message ) ?. testItem ;
205+ }
206+
207+ private getTestInfo ( message : string ) : ITestInfo | undefined {
195208 const index : string = message . substring ( 0 , message . indexOf ( ',' ) ) . trim ( ) ;
196- return this . testOutputMapping . get ( index ) ?. testItem ;
209+ return this . testOutputMapping . get ( index ) ;
197210 }
198211
199212 protected getTestId ( message : string ) : string {
@@ -406,6 +419,7 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
406419 testId,
407420 testCount,
408421 testItem,
422+ isSuite,
409423 } ) ;
410424 }
411425
@@ -424,7 +438,15 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
424438 testId,
425439 testCount,
426440 testItem,
441+ isSuite,
427442 } ) ;
443+ if ( isSuite && testItem ) {
444+ this . suiteItems . add ( testItem ) ;
445+ }
446+ if ( ! isSuite && testItem && ! this . enqueuedTests . has ( testItem ) ) {
447+ this . enqueuedTests . add ( testItem ) ;
448+ this . testContext . testRun . enqueued ( testItem ) ;
449+ }
428450 }
429451 }
430452
@@ -526,6 +548,7 @@ interface ITestInfo {
526548 testId : string ;
527549 testCount : number ;
528550 testItem : TestItem | undefined ;
551+ isSuite : boolean ;
529552}
530553
531554enum RecordingType {
0 commit comments