@@ -17,6 +17,7 @@ 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 ( ) ;
2021
2122 // tests may be run concurrently, so each item's current state needs to be remembered
2223 private currentStates : Map < TestItem , CurrentItemState > = new Map ( ) ;
@@ -67,27 +68,29 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
6768 if ( data . startsWith ( MessageId . TestTree ) ) {
6869 this . enlistToTestMapping ( data . substring ( MessageId . TestTree . length ) . trim ( ) ) ;
6970 } else if ( data . startsWith ( MessageId . TestStart ) ) {
70- const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestStart . length ) ) ;
71- if ( ! item ) {
71+ const testInfo : ITestInfo | undefined = this . getTestInfo ( data . substr ( MessageId . TestStart . length ) ) ;
72+ if ( ! testInfo ?. testItem ) {
7273 return ;
7374 }
74- this . initializeParentState ( item , this . triggeredTestsMapping ) ;
75+ const item : TestItem = testInfo . testItem ;
7576 this . setCurrentState ( item , TestResultState . Running , 0 ) ;
7677 this . setDurationAtStart ( this . getCurrentState ( item ) ) ;
77- setTestState ( this . testContext . testRun , item , this . getCurrentState ( item ) . resultState ) ;
78- this . updateParentOnChildStart ( item ) ;
78+ if ( ! testInfo . isSuite ) {
79+ setTestState ( this . testContext . testRun , item , this . getCurrentState ( item ) . resultState ) ;
80+ }
7981 } else if ( data . startsWith ( MessageId . TestEnd ) ) {
80- const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestEnd . length ) ) ;
81- if ( ! item ) {
82+ const testInfo : ITestInfo | undefined = this . getTestInfo ( data . substr ( MessageId . TestEnd . length ) ) ;
83+ if ( ! testInfo ?. testItem ) {
8284 return ;
8385 }
86+ const item : TestItem = testInfo . testItem ;
8487 const currentState : CurrentItemState = this . getCurrentState ( item ) ;
8588 this . calcDurationAtEnd ( currentState ) ;
8689 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 ) ;
90+ if ( ! testInfo . isSuite ||
91+ currentState . resultState === TestResultState . Failed ||
92+ currentState . resultState === TestResultState . Errored ) {
93+ setTestState ( this . testContext . testRun , item , currentState . resultState , undefined , currentState . duration ) ;
9194 }
9295 } else if ( data . startsWith ( MessageId . TestFailed ) ) {
9396 const item : TestItem | undefined = this . getTestItem ( data . substr ( MessageId . TestFailed . length ) ) ;
@@ -121,14 +124,16 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
121124 return ;
122125 }
123126 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 ) ;
127+ if ( currentResultState !== TestResultState . Skipped ) {
128+ if ( this . assertionFailure ) {
129+ this . tryAppendMessage ( this . tracingItem , this . assertionFailure , currentResultState ) ;
130+ }
131+ if ( this . traces ?. value ) {
132+ this . tryAppendMessage ( this . tracingItem , new TestMessage ( this . traces ) , currentResultState ) ;
133+ }
134+ if ( currentResultState === TestResultState . Errored ) {
135+ setTestState ( this . testContext . testRun , this . tracingItem , currentResultState ) ;
136+ }
132137 }
133138 this . recordingType = RecordingType . None ;
134139 } else if ( data . startsWith ( MessageId . ExpectStart ) ) {
@@ -192,8 +197,12 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
192197 }
193198
194199 protected getTestItem ( message : string ) : TestItem | undefined {
200+ return this . getTestInfo ( message ) ?. testItem ;
201+ }
202+
203+ private getTestInfo ( message : string ) : ITestInfo | undefined {
195204 const index : string = message . substring ( 0 , message . indexOf ( ',' ) ) . trim ( ) ;
196- return this . testOutputMapping . get ( index ) ?. testItem ;
205+ return this . testOutputMapping . get ( index ) ;
197206 }
198207
199208 protected getTestId ( message : string ) : string {
@@ -406,6 +415,7 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
406415 testId,
407416 testCount,
408417 testItem,
418+ isSuite,
409419 } ) ;
410420 }
411421
@@ -424,7 +434,12 @@ export class JUnitRunnerResultAnalyzer extends RunnerResultAnalyzer {
424434 testId,
425435 testCount,
426436 testItem,
437+ isSuite,
427438 } ) ;
439+ if ( ! isSuite && testItem && ! this . enqueuedTests . has ( testItem ) ) {
440+ this . enqueuedTests . add ( testItem ) ;
441+ this . testContext . testRun . enqueued ( testItem ) ;
442+ }
428443 }
429444 }
430445
@@ -526,6 +541,7 @@ interface ITestInfo {
526541 testId : string ;
527542 testCount : number ;
528543 testItem : TestItem | undefined ;
544+ isSuite : boolean ;
529545}
530546
531547enum RecordingType {
0 commit comments