简体   繁体   English

在模拟器中查看 Flutter 小部件测试

[英]View Flutter widget tests in simulator

Is there a way to see the UI tests in the simulator?有没有办法在模拟器中查看 UI 测试?

I am writing some tests for a widget which has animation and want to verify my tests are triggering the animation correctly.我正在为具有动画的小部件编写一些测试,并希望验证我的测试是否正确触发了动画。

Found the answer from the Docs page:从文档页面找到答案

To help debug widget tests, you can use the debugDumpApp() function to visualize the UI state of your test or simply flutter run test/widget_test.dart to see your test run in your preferred runtime environment such as a simulator or a device.为了帮助调试小部件测试,您可以使用 debugDumpApp() 函数来可视化您的测试的 UI 状态,或者简单地 flutter run test/widget_test.dart 以查看您在首选运行时环境(例如模拟器或设备)中运行的测试。 During a flutter run session on a widget test, you can also interactively tap parts of the screen for the Flutter tool to print the suggested Finder.在小部件测试的 flutter 运行会话期间,您还可以交互式地点击屏幕的某些部分,以便 Flutter 工具打印建议的 Finder。

run from command line从命令行运行

 flutter run -t test/your_test.dart

-t is for target file -t 用于目标文件

if it tells you it couldnt find the apk you may have to tell it which flavor to use like this如果它告诉您找不到该 apk,您可能必须像这样告诉它使用哪种口味

flutter run --flavor uat -t test/your_test.dart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM