【问题标题】:How to find if we are running unit test in Dart (Flutter)如何找到我们是否在 Dart (Flutter) 中运行单元测试
【发布时间】:2019-11-25 09:25:47
【问题描述】:

在 Flutter (Dart) 中从单元测试调用函数时,我如何确定我是在运行单元测试还是实际应用程序? 如果在单元测试中,我想传递不同的数据。

【问题讨论】:

标签: android unit-testing flutter dart


【解决方案1】:

您可以使用以下内容来检查您是否正在运行测试。

Platform.environment.containsKey('FLUTTER_TEST')

【讨论】:

  • Platform 定义在dart:io
猜你喜欢
  • 2020-05-12
  • 2020-05-05
  • 2020-01-18
  • 2020-01-18
  • 2021-11-16
  • 1970-01-01
  • 2017-11-07
  • 1970-01-01
  • 2017-11-07
相关资源
最近更新 更多