flutter - Flutter test_driver 执行报告

标签 flutter dart flutter-test

我需要生成一份报告,说明执行了多少测试、失败了多少、测试失败的原因。是否有一些选项可以使用 test_driver 来完成?
我们可以使用命令 flutter test --machine 为 flutter 单元测试生成 json 报告。 flutter drive 有相同的东西吗?

最佳答案

虽然 flutter driver 不会生成开箱即用的完整测试摘要报告,但有一种替代方法可以使用 flutter_gherkin 来完成。插入。该插件使用 ATDD 风格编写集成测试,利用 Flutter 驱动程序及其方法。

检查插件仓库中的示例。

此插件有一个配置文件(就像 Google Espresso 中的检测文件),它有一个 reporter 参数来指定生成 json 格式报告的 json 报告器。 下面是生成的json报告内容:

[{
    "keyword": "Feature",
    "uri": "./test_driver/features/custom_parameter_example.feature",
    "id": "custom parameter example",
    "name": "Custom Parameter Example",
    "description": "",
    "line": 0,
    "elements": [{
        "keyword": "Scenario",
        "type": "scenario",
        "id": "custom parameter example;custom colour parameter",
        "name": "Custom colour parameter",
        "description": "",
        "line": 3,
        "steps": [{
            "keyword": "Given ",
            "name": "I pick the colour red",
            "line": 4,
            "result": {
                "status": "passed",
                "duration": 6000000
            }
        }, {
            "keyword": "Given ",

然后可以根据您的要求使用 cucumber-html-reporter 将此报告转换为 html 报告。

这种方法听起来有点乏味,而且格式可能是也可能不是您想要的方式,因为您可能需要以 Given When Then 格式重新编写测试,以便 json 报告生成,但您可以尝试使用这种方法,看看它是否适合您。

关于flutter - Flutter test_driver 执行报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56954969/

相关文章:

flutter - 无法从flutter_sound包成功调用startRecorder(uri:…)

firebase - Flutter-PlatformException:错误,无效的文档引用。文档引用的段数必须为偶数,但用户的段数为1,则为null

flutter - 谁能说出Flutter中 “flutter_bloc”和 “bloc”软件包的区别

flutter 2.0 : nested MaterialApps -> problem with textInput inside showModalBottomSheet

flutter - 使用 getter 模式而不是典型的不可变成员会带来什么影响?

firebase - Flutter cloud_firestore 系统日期对象的设置/警告

multithreading - 如何处理 Isolates 中抛出的异常?

firebase - 对于与用户uid相同的文档ID,如何从Firestore中仅检索一个用户的数据?

listview - Flutter ListView.builder() 动态列表 - 显示无限重复的条目

flutter - 如何在 flutter 时禁用自动热重载?