Home > front end >  How to provide test flags when debugging a single test?
How to provide test flags when debugging a single test?

Time:10-29

How can I pass test flags (e.g. the -test.v and -test.vet=off flags) to the test program when debugging a single test, i.e. when I use the Go: Debug Test at Cursor functionality?

The go.testFlags section from the workspace settings contains these settings, too - but it seems that they only have an effect when running the test (Go: Run Test at Cursor).

I am using Visual Studio Code 1.61.2, vscode-go v0.28.1, and the dlv-dap that is auto-installed.

CodePudding user response:

The issue might come from src/goTest.ts#_testAtCursor()

    if (cmd === 'debug') {
        return debugTestAtCursor(editor, testFunctionName, testFunctions, goConfig);
    } else if (cmd === 'benchmark' || cmd === 'test') {
        return runTestAtCursor(editor, testFunctionName, testFunctions, goConfig, cmd, args);
    } else {
        throw new Error(`Unsupported command: ${cmd}`);
    }

There is no cmd, args when calling debugTestAtCursor(), as opposed to runTestAtCursor().
That could mean this is not supported in the current implementation.

  • Related