当 运行ning test from 运行 button in VSCODE 时设置环境变量

set an environment variable when running test from run button in VSCODE

我正在 Flutter 中创建一些测试,但我需要在 运行 测试之前设置一个环境变量。 运行 来自这些 "Run | Debug" 按钮的应用程序时,有没有办法设置环境变量?

随着 Dart SDK 的新更新,可以: https://dartcode.org/releases/v3-11/

[...] 例如,为启动配置添加 CodeLens,将 RELEASE_MODE=true 环境变量设置为 test/integration_tests:

中的测试
{
    "name": "Current File (release mode)",
    "type": "dart",
    "request": "launch",
    "codeLens": {
        // Types of CodeLens to inject
        "for": [ "run-test", "run-test-file", "debug-test", "debug-test-file" ],
        // Restrict to certain folders
        "path": "test/integration_tests",
        // Text for CodeLens link (${debugType} will be replaced with "run" or "debug")
        "title": "${debugType} (release)"
    },
    "env": { "RELEASE_MODE": true }
}

这会将额外的 CodeLens 链接插入到测试、组和主要功能中: