@@ -46,8 +46,10 @@ export class NbTestAdapter {
46
46
}
47
47
48
48
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
+ }
51
53
this . testController . items . replace ( [ ] ) ;
52
54
this . load ( ) ;
53
55
}
@@ -165,20 +167,33 @@ export class NbTestAdapter {
165
167
166
168
dispatchTestEvent ( state : SuiteState , testItem : TestItem ) : void {
167
169
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
+ }
174
181
} else if ( testItem . children . size === 0 ) {
175
182
const testSuite = testItem . parent ;
183
+ const parentState = testSuite && this . suiteStates . get ( testSuite ) ? this . suiteStates . get ( testSuite ) : state ;
176
184
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
+ }
177
192
const testSuiteEvent : any = {
178
193
name : testSuite . id ,
179
- moduleName : testSuite . parent ?. id ,
180
- modulePath : testSuite . parent ?. uri ?. path ,
181
- state,
194
+ moduleName,
195
+ modulePath,
196
+ state : parentState ,
182
197
tests : [ ]
183
198
}
184
199
testSuite ?. children . forEach ( suite => {
@@ -199,6 +214,24 @@ export class NbTestAdapter {
199
214
}
200
215
}
201
216
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
+
202
235
dispatchEvent ( event : any ) : void {
203
236
const testProgressListeners = listeners . get ( TEST_PROGRESS_EVENT ) ;
204
237
testProgressListeners ?. forEach ( listener => {
0 commit comments