[英]How to do integration testing in Flutter?
I want to do integration testing in Flutter. 我想在Flutter中进行集成测试。 The tutorial I follow gives the following procedure:
我遵循的教程提供了以下过程:
dev_dependencies:
flutter_driver:
sdk: flutter
My problem is with understanding step 2. It's not clear to me where in Android Studio do you enable the driver extension and where exactly in main.dart do you call the function enableFlutterDriveExtension(). 我的问题在于理解第2步。我不清楚在Android Studio中你在哪里启用驱动程序扩展,在main.dart中你究竟在哪里调用函数enableFlutterDriveExtension()。
I also have problems with the third step. 第三步我也有问题。 After running the said command, it says in my terminal that
运行上述命令后,它在我的终端中说
Error: The Flutter directory is not a clone of the GitHub project.
The flutter tool requires Git in order to operate properly;
to set up Flutter, run the following command:
git clone -b stable https://github.com/flutter/flutter.git
You have to add this code inside the test_driver/app.dart file. 您必须在test_driver / app.dart文件中添加此代码。
import 'package:flutter_driver/driver_extension.dart';
import 'package:[YOUR_APP]/main.dart' as app;
void main() {
// This line enables the extension
enableFlutterDriverExtension();
// Call the `main()` function of your app or call `runApp` with any widget you
// are interested in testing.
app.main();
}
You can find more info on the official Flutter documentation site (Steps 3 & 4): https://flutter.dev/docs/cookbook/testing/integration/introduction 您可以在官方Flutter文档站点上找到更多信息(步骤3和4): https : //flutter.dev/docs/cookbook/testing/integration/introduction
Good luck ;) 祝好运 ;)
In order to run integration test in flutter, you need to create "test_driver" directory inside app root dir. 为了在flutter中运行集成测试,您需要在app root dir中创建“test_driver”目录。 Than you need to create two files inside "test_driver" folder.
比你需要在“test_driver”文件夹中创建两个文件。
When you want to run that test, just run "flutter drive --target=test_driver/app.dart". 如果要运行该测试,只需运行“flutter drive --target = test_driver / app.dart”。
About step 3 in your question, check if you set flutter home properly and after adding flutter_driver dependency, run "packages get". 关于问题中的第3步,检查是否正确设置了flutter home,并在添加flutter_driver依赖项后,运行“packages get”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.