src/goTest.ts: prompt for subtest name if there is no subtest at cursor

Updates golang/vscode-go#1602

Change-Id: Ibcea9c5980c6c08257f0c6925502eb0b9fd00cdb
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/333309
Trust: Suzy Mueller <suzmue@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/src/goTest.ts b/src/goTest.ts
index bbf95c8..325c08c 100644
--- a/src/goTest.ts
+++ b/src/goTest.ts
@@ -175,12 +175,22 @@
 			}
 		}
 
+		let subtest: string;
 		if (!simpleMatch) {
-			vscode.window.showInformationMessage('No subtest function with a simple subtest name found at cursor.');
-			return;
+			const input = await vscode.window.showInputBox({
+				prompt: 'Enter sub test name'
+			});
+			if (input) {
+				subtest = input;
+			} else {
+				vscode.window.showInformationMessage('No subtest function with a simple subtest name found at cursor.');
+				return;
+			}
+		} else {
+			subtest = simpleMatch[1];
 		}
 
-		const subTestName = testFunctionName + '/' + simpleMatch[1];
+		const subTestName = testFunctionName + '/' + subtest;
 
 		return await runTestAtCursor(editor, subTestName, testFunctions, goConfig, 'test', args);
 	} catch (err) {
diff --git a/test/integration/codelens.test.ts b/test/integration/codelens.test.ts
index bbe2f61..7d522d3 100644
--- a/test/integration/codelens.test.ts
+++ b/test/integration/codelens.test.ts
@@ -85,10 +85,19 @@
 	test('Subtests - does nothing for a dynamically defined subtest', async () => {
 		const editor = await vscode.window.showTextDocument(document);
 		editor.selection = new vscode.Selection(17, 4, 17, 4);
+		sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves(undefined);
 		const result = await subTestAtCursor(goConfig, []);
 		assert.equal(result, undefined);
 	});
 
+	test('Subtests - runs a test with curson on t.Run line and dynamic test name is passed in input box', async () => {
+		const editor = await vscode.window.showTextDocument(document);
+		editor.selection = new vscode.Selection(17, 4, 17, 4);
+		sinon.stub(vscode.window, 'showInputBox').onFirstCall().resolves('dynamic test name');
+		const result = await subTestAtCursor(goConfig, []);
+		assert.equal(result, false);
+	});
+
 	test('Subtests - does nothing when cursor outside of a test function', async () => {
 		const editor = await vscode.window.showTextDocument(document);
 		editor.selection = new vscode.Selection(5, 0, 5, 0);