@@ -38,8 +38,8 @@ export class PesterTestsFeature implements IFeature {
38
38
// This command is provided for usage by PowerShellEditorServices (PSES) only
39
39
this . command = vscode . commands . registerCommand (
40
40
"PowerShell.RunPesterTests" ,
41
- ( uriString , runInDebugger , describeBlockName ?, describeBlockLineNumber ?) => {
42
- this . launchTests ( uriString , runInDebugger , describeBlockName , describeBlockLineNumber ) ;
41
+ ( uriString , runInDebugger , describeBlockName ?, describeBlockLineNumber ?, outputPath ? ) => {
42
+ this . launchTests ( uriString , runInDebugger , describeBlockName , describeBlockLineNumber , outputPath ) ;
43
43
} ) ;
44
44
}
45
45
@@ -52,24 +52,30 @@ export class PesterTestsFeature implements IFeature {
52
52
}
53
53
54
54
private launchAllTestsInActiveEditor ( launchType : LaunchType , fileUri : vscode . Uri ) {
55
- const uriString = fileUri . toString ( ) ;
55
+ const uriString = ( fileUri || vscode . window . activeTextEditor . document . uri ) . toString ( ) ;
56
56
const launchConfig = this . createLaunchConfig ( uriString , launchType ) ;
57
- launchConfig . args . push ( "-All" ) ;
58
57
this . launch ( launchConfig ) ;
59
58
}
60
59
61
60
private async launchTests (
62
61
uriString : string ,
63
62
runInDebugger : boolean ,
64
63
describeBlockName ?: string ,
65
- describeBlockLineNumber ?: number ) {
64
+ describeBlockLineNumber ?: number ,
65
+ outputPath ?: string ) {
66
66
67
67
const launchType = runInDebugger ? LaunchType . Debug : LaunchType . Run ;
68
- const launchConfig = this . createLaunchConfig ( uriString , launchType , describeBlockName , describeBlockLineNumber ) ;
68
+ const launchConfig = this . createLaunchConfig ( uriString , launchType , describeBlockName , describeBlockLineNumber , outputPath ) ;
69
69
this . launch ( launchConfig ) ;
70
70
}
71
71
72
- private createLaunchConfig ( uriString : string , launchType : LaunchType , testName ?: string , lineNum ?: number ) {
72
+ private createLaunchConfig (
73
+ uriString : string ,
74
+ launchType : LaunchType ,
75
+ testName ?: string ,
76
+ lineNum ?: number ,
77
+ outputPath ?: string ) {
78
+
73
79
const uri = vscode . Uri . parse ( uriString ) ;
74
80
const currentDocument = vscode . window . activeTextEditor . document ;
75
81
const settings = Settings . load ( ) ;
@@ -98,15 +104,15 @@ export class PesterTestsFeature implements IFeature {
98
104
99
105
if ( lineNum ) {
100
106
launchConfig . args . push ( "-LineNumber" , `${ lineNum } ` ) ;
101
- }
102
-
103
- if ( testName ) {
107
+ } else if ( testName ) {
104
108
// Escape single quotes inside double quotes by doubling them up
105
109
if ( testName . includes ( "'" ) ) {
106
110
testName = testName . replace ( / ' / g, "''" ) ;
107
111
}
108
112
109
113
launchConfig . args . push ( "-TestName" , `'${ testName } '` ) ;
114
+ } else {
115
+ launchConfig . args . push ( "-All" ) ;
110
116
}
111
117
112
118
if ( ! settings . pester . useLegacyCodeLens ) {
@@ -120,6 +126,10 @@ export class PesterTestsFeature implements IFeature {
120
126
launchConfig . args . push ( "-Output" , `'${ settings . pester . outputVerbosity } '` ) ;
121
127
}
122
128
129
+ if ( outputPath ) {
130
+ launchConfig . args . push ( "-OutputPath" , `'${ outputPath } '` ) ;
131
+ }
132
+
123
133
return launchConfig ;
124
134
}
125
135
0 commit comments