如何自动执行Flutter Integration测试命令? [英] How to automate Flutter Integration testing command?

查看:114
本文介绍了如何自动执行Flutter Integration测试命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读并尝试了Flutter的集成测试.我在这里遵循了本指南...

I've read and tried integration testing with flutter. I followed this guide here...

https://flutter.io/docs/cookbook/testing/integration

现在,要运行集成测试,我必须输入以下命令:

Now, to run the integration test I have to type in the following command:

flutter drive --target=test_driver/app.dart

我的问题是,有没有一种方法可以在android studio中自动执行此操作,因此我不必手动键入命令.我宁愿只单击一个按钮并运行集成测试,而不是一遍又一遍地键入命令.

My question is, is there a way to automate this inside android studio so I do not have to type in the command manually. I rather just click one button and run the integration test than type the command over and over again.

我对所有事物都是陌生的,因此任何建议将不胜感激.预先感谢.

I'm new in flutter over all so any suggestion will be very much appreciated. Thanks in advance.

推荐答案

不确定您是否找到问题的答案,但是我将在此处发布解决方案.希望对您有所帮助.

Not sure if you found answer for your question, but I am going to post solution here. Hope it helps.

  1. 在Android Studio中,打开run/edit configuration dialog并选择如下的Edit Configurations:
  1. In Android Studio, open the run/edit configuration dialog and select Edit Configurations as below:

  1. 单击+按钮,然后选择Dart Command Line App配置.

  1. 为配置命名(例如:integration.dart),然后选择以下内容:

Dart文件:具有集成测试的Dart文件的路径. (例如:app_test.dart)

Dart file: the path of the dart file which has integration test. (ex: app_test.dart)

工作目录:项目的根路径.

Working directory: root path of your project.

环境变量:单击此字段中最右边的文件夹图标,然后创建新的环境变量,如下所示:

Environment variables: click on folder icon at extreme right in this field and create new environment variable as below:

请注意,根据您的情况,http网址将有所不同.为了发现这一点,请在终端中运行flutter命令,并注意控制台中显示的observatory url.就我而言,它位于以下位置:

Note that, the http url will be different in your case. In order to find out that, run the flutter command in terminal and note the observatory url displayed in the console. In my case, it was below:

flutter: Observatory listening on http://127.0.0.1:51150/

用您的替换它,然后单击确定.

Replace it with yours and click OK.

正确完成上述步骤并运行integration.dart配置后,您应该能够从Android Studio运行命令并在IDE中查看结果.

Once you complete above steps properly and run the integration.dart configuration, you should be able to run the command from Android Studio and see the results in IDE.

这篇关于如何自动执行Flutter Integration测试命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆