首页 > 解决方案 > 使用 integration_test 包进行 Flutter 集成测试调试

问题描述

我正在使用 integration_test 包编写集成测试。它运作良好。

我在 CLI 中运行以下命令来开始测试。

flutter drive --driver=test_driver/integration_test_driver.dart --target=test/integration_tests/app_test.dart

但是每次我重新运行测试时都需要重建应用程序。能否避免 App 的重建?

也可以将调试器附加到测试用例,如调试单元或小部件测试。

标签: flutterdebuggingflutter-test

解决方案


如果您使用的是 VS Code,则可以添加配置launch.json来运行测试。将“程序”属性设置为集成测试的路径。

   {
        "name": "Integration Test: Run Test",
        "program": "project_root/integration_test/foo_test.dart",
        "request": "launch",
        "type": "dart"
    },

然后您可以在测试中添加断点来暂停执行。您也可以通过 VS Code 重新启动程序,测试将再次运行。如果你不使用 VS Code,在 ANdroid studio 中设置类似的配置应该很容易。


推荐阅读