【问题标题】:How to provide test flags when debugging a single test?调试单个测试时如何提供测试标志?
【发布时间】:2021-10-26 16:49:17
【问题描述】:
在调试单个测试时,即当我使用 Go: Debug Test at Cursor 功能时,如何将测试标志(例如 -test.v 和 -test.vet=off 标志)传递给测试程序?
工作区设置中的go.testFlags 部分也包含这些设置 - 但它们似乎只在运行测试时起作用(Go: Run Test at Cursor)。
我正在使用 Visual Studio Code 1.61.2、vscode-go v0.28.1 和自动安装的 dlv-dap。
【问题讨论】:
标签:
go
visual-studio-code
vscode-debugger
delve
【解决方案1】:
问题可能来自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}`);
}
调用debugTestAtCursor() 时没有cmd, args,而不是runTestAtCursor()。
这可能意味着当前实现不支持此功能。