Users complain that the handy run test | debug test links above their test functions ignore the flags they set in their launch configuration (example, example, example). They can fallback on settings.json using go.testFlags, go.delveConfig, etc, but that is not obvious or intuitive and has surprised users with additional limitations for debug test vs run test (e.g. #1636, microsoft/vscode-go#2894 (comment), microsoft/vscode-go#2115 (comment)).
According to @ramya-rao-a, a while back there was no way to feed current selected launch configuration into the codelens, so another set of dlv-related settings was supported as an alternative. Since then a new mechanism to support this could have been introduced, so we should investigate what is possible now.
Below is a quick way to reproduce the current behavior:
Test function:
func TestA(t *testing.T) {
log.Println("TestA running")
if !testing.Verbose() {
t.Fatal()
}
}
Selected launch configuration
{
"name": "Launch test function",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}",
"args": [
"-test.run", "TestA", // no impact with or without on `run/debug test`, which adds its own `-run ^TestA$`
"-test.v"
]
},
Debug with ▷ Start Debugging or Run > Start Debugging (F5)
Uses launch.json configuration, so the test passes.

Debug with debug test
Doesn't use launch.json configuration, so the test fails.

Run with Run > Run Without Debugging (^F5)
Uses launch.json configuration, so the test passes. (Note that this actually goes through the debug adapter, which launches dlv - see #336)

Run with run test
Doesn't use launch.json configuration, so the test fails. (Note that this uses go test and bypasses dlv - see #336)

Adding flags to settings.json
"go.testFlags": ["-test.v"]
run test now passes, but debug test behavior is unchanged.
"go.testFlags": ["-args","-test.v"]
run test passes, but only prints "ok", no details. debug test works as expected.
"go.testFlags": ["-v", "-args","-test.v"]
Combining these makes both work as expected - pass and print verbose details.
Users complain that the handy
run test | debug testlinks above their test functions ignore the flags they set in their launch configuration (example, example, example). They can fallback onsettings.jsonusinggo.testFlags,go.delveConfig, etc, but that is not obvious or intuitive and has surprised users with additional limitations fordebug testvsrun test(e.g. #1636, microsoft/vscode-go#2894 (comment), microsoft/vscode-go#2115 (comment)).According to @ramya-rao-a, a while back there was no way to feed current selected launch configuration into the codelens, so another set of dlv-related settings was supported as an alternative. Since then a new mechanism to support this could have been introduced, so we should investigate what is possible now.
Below is a quick way to reproduce the current behavior:
Test function:
Selected launch configuration
Debug with
▷ Start DebuggingorRun > Start Debugging (F5)Uses

launch.jsonconfiguration, so the test passes.Debug with
debug testDoesn't use

launch.jsonconfiguration, so the test fails.Run with
Run > Run Without Debugging (^F5)Uses

launch.jsonconfiguration, so the test passes. (Note that this actually goes through the debug adapter, which launches dlv - see #336)Run with
run testDoesn't use

launch.jsonconfiguration, so the test fails. (Note that this usesgo testand bypasses dlv - see #336)Adding flags to
settings.jsonrun testnow passes, butdebug testbehavior is unchanged.run testpasses, but only prints "ok", no details.debug testworks as expected.Combining these makes both work as expected - pass and print verbose details.