Flutter Integration_test - 在 VS Code 中添加 --flavor 参数

Luk*_*rse 6 visual-studio-code flutter flutter-test flutter-integration-test

我有一套针对 Flutter 应用程序的集成测试。我想使用 VS Code 测试选项卡运行它们,以便我可以轻松查看有关哪些测试通过/失败的信息等。

VS Code 测试视图

在我们实现flavor之前,这工作得很好。现在,口味已在 launch.json 中定义,运行测试需要 --flavor 参数,但我似乎无法在 UI 中设置它。

如果我尝试使用 VS Code 中的“测试”选项卡在 iOS 上运行它们,则会收到以下错误:

The Xcode project defines schemes: dev, prod, qa Exception: You must specify a --flavor option to select one of the available schemes.

我可以运行flutter test integration_test --flavor dev,但终端充满了日志,很难找出哪些测试失败以及原因。

Han*_*nes 1

我也只是在挣扎。您需要将其添加到 launch.json 中:

{
        "name": "integration test",
        "request": "launch",
        "type": "dart",
        // Define your flavor (here: foo) that you use in tests
        "toolArgs": [
            "--flavor",
            "foo",
        ],
        // This is important: set it only for integration_test
        "templateFor": "integration_test",
    },
Run Code Online (Sandbox Code Playgroud)

就是这样!现在您也可以在 VSCode 上运行它们。