@@ -159,6 +159,7 @@ export class TestResolver implements OnModuleInit, vscode.Disposable {
159
159
parentTest ,
160
160
'Loading: waiting for build server connection'
161
161
)
162
+ parentTest . error = undefined
162
163
const conn = await this . buildServer . getConnection ( )
163
164
164
165
updateDescription ( parentTest , 'Loading: fetching available targets' )
@@ -212,6 +213,25 @@ export class TestResolver implements OnModuleInit, vscode.Disposable {
212
213
relevantParent . children . add ( newTest )
213
214
} )
214
215
216
+ // If no test items were added, show the getting started message as a test message overlaid on the .bazelproject file.
217
+ // This provides an opportunity for the user to make adjustments and re-sync.
218
+ if ( parentTest . children . size === 0 ) {
219
+ // Dummy test run that overlays the getting started message on the .bazelproject file.
220
+ const run = this . store . testController . createTestRun (
221
+ new vscode . TestRunRequest ( )
222
+ )
223
+ run . errored ( parentTest , new vscode . TestMessage ( gettingStartedMessage ) )
224
+ run . end ( )
225
+
226
+ // Link in the test explorer tree to set up the project.
227
+ const encodedFileUri = encodeURIComponent ( JSON . stringify ( parentTest . uri ) )
228
+ const syncFailMessage = new vscode . MarkdownString (
229
+ `No test targets found. [Setup your project](command:vscode.open?${ encodedFileUri } )`
230
+ )
231
+ syncFailMessage . isTrusted = true
232
+ parentTest . error = syncFailMessage
233
+ }
234
+
215
235
// Replace all children with the newly returned test cases.
216
236
this . condenseTestItems ( parentTest )
217
237
updateDescription ( parentTest )
@@ -413,3 +433,19 @@ function combineCancelTokens(
413
433
token2 ?. onCancellationRequested ( ( ) => combinedSource . cancel ( ) )
414
434
return combinedSource . token
415
435
}
436
+
437
+ const gettingStartedMessage = new vscode . MarkdownString (
438
+ `To use the Test Explorer, please configure your project.
439
+
440
+ Getting started tips:
441
+ - Update this file with some paths that include test targets.
442
+ - Use the directories key to specify by directory
443
+ - Use the targets key to specify by Bazel target pattern
444
+ - Ensure that the bazel_binary field in this file matches the path to your Bazel binary.
445
+ - Re-sync at any time by clicking the $(extensions-refresh) refresh icon at the very top of the testing panel.
446
+
447
+ Think something else went wrong? Check the output [here](command:bazelbsp.showServerOutput).
448
+ ` ,
449
+ true
450
+ )
451
+ gettingStartedMessage . isTrusted = true
0 commit comments