@@ -46,8 +46,10 @@ export class NbTestAdapter {
4646 }
4747
4848 public registerRunInParallelProfile ( projects : string [ ] ) {
49- const runHandler = ( request : TestRunRequest , cancellation : CancellationToken ) => this . run ( request , cancellation , true , projects ) ;
50- this . parallelRunProfile = this . testController . createRunProfile ( "Run Tests In Parallel" , TestRunProfileKind . Run , runHandler , true ) ;
49+ if ( ! this . parallelRunProfile ) {
50+ const runHandler = ( request : TestRunRequest , cancellation : CancellationToken ) => this . run ( request , cancellation , true , projects ) ;
51+ this . parallelRunProfile = this . testController . createRunProfile ( "Run Tests In Parallel" , TestRunProfileKind . Run , runHandler , true ) ;
52+ }
5153 this . testController . items . replace ( [ ] ) ;
5254 this . load ( ) ;
5355 }
@@ -165,20 +167,33 @@ export class NbTestAdapter {
165167
166168 dispatchTestEvent ( state : SuiteState , testItem : TestItem ) : void {
167169 if ( testItem . parent && testItem . children . size > 0 ) {
168- this . dispatchEvent ( {
169- name : testItem . id ,
170- moduleName : testItem . parent . id ,
171- modulePath : testItem . parent . uri ?. path ,
172- state,
173- } ) ;
170+ if ( testItem . id . includes ( ":" ) && testItem . parent . parent ) {
171+ // special case when parameterized test
172+ this . dispatchEvent ( this . getParametrizedTestEvent ( state , testItem ) ) ;
173+ } else {
174+ this . dispatchEvent ( {
175+ name : testItem . id ,
176+ moduleName : testItem . parent . id ,
177+ modulePath : testItem . parent . uri ?. path ,
178+ state,
179+ } ) ;
180+ }
174181 } else if ( testItem . children . size === 0 ) {
175182 const testSuite = testItem . parent ;
183+ const parentState = testSuite && this . suiteStates . get ( testSuite ) ? this . suiteStates . get ( testSuite ) : state ;
176184 if ( testSuite ) {
185+ let moduleName = testSuite . parent ?. id ;
186+ let modulePath = testSuite . parent ?. uri ?. path ;
187+ if ( testSuite . id . includes ( ":" ) && testSuite . parent ?. parent ) {
188+ // special case when parameterized test
189+ moduleName = testSuite . parent . parent . id ;
190+ modulePath = testSuite . parent . parent . uri ?. path ;
191+ }
177192 const testSuiteEvent : any = {
178193 name : testSuite . id ,
179- moduleName : testSuite . parent ?. id ,
180- modulePath : testSuite . parent ?. uri ?. path ,
181- state,
194+ moduleName,
195+ modulePath,
196+ state : parentState ,
182197 tests : [ ]
183198 }
184199 testSuite ?. children . forEach ( suite => {
@@ -199,6 +214,24 @@ export class NbTestAdapter {
199214 }
200215 }
201216
217+ getParametrizedTestEvent ( state : SuiteState , testItem : TestItem ) : any {
218+ let name = testItem . parent ?. id ;
219+ const idx = name ?. indexOf ( ':' ) || 0 ;
220+ return {
221+ name,
222+ moduleName : testItem . parent ?. parent ?. id ,
223+ modulePath : testItem . parent ?. parent ?. uri ?. path ,
224+ state,
225+ tests : [
226+ {
227+ id : name ,
228+ name : name ?. slice ( idx + 1 ) ,
229+ state
230+ }
231+ ]
232+ }
233+ }
234+
202235 dispatchEvent ( event : any ) : void {
203236 const testProgressListeners = listeners . get ( TEST_PROGRESS_EVENT ) ;
204237 testProgressListeners ?. forEach ( listener => {
0 commit comments