栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何将环境变量传递给Flutter驱动程序测试

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何将环境变量传递给Flutter驱动程序测试

Platform.environment
在运行驱动程序测试之前,我尝试使用Dart
读取环境变量,它似乎工作正常。下面是一个简单的示例,该示例使用
FLUTTER_DRIVER_RESULTS
env变量设置测试摘要的输出目录。

import 'dart:async';import 'dart:io' show Platform;import 'package:flutter_driver/flutter_driver.dart';import 'package:test/test.dart';void main() {  // Load environmental variables  String resultsDirectory =    Platform.environment['FLUTTER_DRIVER_RESULTS'] ?? '/tmp';  print('Results directory is $resultsDirectory');  group('increment button test', () {    FlutterDriver driver;    setUpAll(() async {      // Connect to the app      driver = await FlutterDriver.connect();    });    tearDownAll(() async {      if (driver != null) {        // Disconnect from the app        driver.close();      }    });    test('measure', () async {      // Record the performance timeline of things that happen      Timeline timeline = await driver.traceAction(() async {        // Find the scrollable user list        SerializableFinder incrementButton = find.byValueKey( 'increment_button');        // Click the button 10 times        for (int i = 0; i < 10; i++) {          await driver.tap(incrementButton);          // Emulate time for a user's finger between taps          await new Future<Null>.delayed(new Duration(milliseconds: 250));        }      });        TimelineSummary summary = new TimelineSummary.summarize(timeline);        summary.writeSummaryToFile('increment_perf', destinationDirectory: resultsDirectory, pretty: true);        summary.writeTimelineToFile('increment_perf', destinationDirectory: resultsDirectory, pretty: true);    });  });}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418557.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号