11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license.
33
4- import { debug , DebugConfiguration , Uri , workspace } from 'vscode' ;
4+ import { debug , DebugConfiguration , DebugSession , Disposable , Uri , workspace } from 'vscode' ;
55import { logger } from '../../logger/logger' ;
66import { BaseRunner } from '../baseRunner/BaseRunner' ;
77import { BaseRunnerResultAnalyzer } from '../baseRunner/BaseRunnerResultAnalyzer' ;
88import { JUnit4RunnerResultAnalyzer } from './JUnit4RunnerResultAnalyzer' ;
99
1010export class JUnit4Runner extends BaseRunner {
1111
12+ private debugSession : DebugSession | undefined ;
13+ private disposables : Disposable [ ] = [ ] ;
14+
15+ public async tearDown ( isCancel : boolean ) : Promise < void > {
16+ super . tearDown ( isCancel ) ;
17+ if ( this . debugSession ) {
18+ this . debugSession . customRequest ( 'disconnect' ) ;
19+ this . debugSession = undefined ;
20+ }
21+ for ( const disposable of this . disposables ) {
22+ disposable . dispose ( ) ;
23+ }
24+ }
25+
1226 protected get testResultAnalyzer ( ) : BaseRunnerResultAnalyzer {
1327 if ( ! this . runnerResultAnalyzer ) {
1428 this . runnerResultAnalyzer = new JUnit4RunnerResultAnalyzer ( this . tests ) ;
@@ -24,6 +38,11 @@ export class JUnit4Runner extends BaseRunner {
2438 const uri : Uri = Uri . parse ( this . tests [ 0 ] . location . uri ) ;
2539 logger . verbose ( `Launching with the following launch configuration: '${ JSON . stringify ( launchConfiguration , null , 2 ) } '\n` ) ;
2640 debug . startDebugging ( workspace . getWorkspaceFolder ( uri ) , launchConfiguration ) ;
41+ this . disposables . push ( debug . onDidStartDebugSession ( ( session : DebugSession ) => {
42+ if ( launchConfiguration . name === session . name ) {
43+ this . debugSession = session ;
44+ }
45+ } ) ) ;
2746 }
2847}
2948
0 commit comments