我可以在Flutter中使用一个配置文件运行多个集成测试吗? [英] Can I run multiple integration tests with one single config file in Flutter?

查看:219
本文介绍了我可以在Flutter中使用一个配置文件运行多个集成测试吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写Flutter集成测试,并使用一个配置文件运行所有测试,而不是为每个测试都创建配置文件.有什么办法吗?

I am trying to write Flutter integration tests and to run them all with one config file instead of making config file for every single test. Is there any way to do that?

目前,对于每个测试,我都有login.dart和login_test.dart等.我知道它的约定,即每个配置和测试文件必须具有相同的名称,但这不是我所需要的,欢迎使用更多可配置的东西.预先感谢.

For now I have login.dart and login_test.dart and so on, for every single test. I know its convention that every config and test file must have the same name, but that's not what I need, more configurable things are welcomed. Thanks in advance.

这是我的配置文件(login.dart)

This is my config file (login.dart)

import 'package:flutter_driver/driver_extension.dart';
import 'package:seve/main.dart' as app;

void main() {
enableFlutterDriverExtension();
app.main();
}

测试(login_test.dart)看起来像这样

And test (login_test.dart) looks something like this

import ...

FlutterDriver driver;

void main() {

setUpAll(() async {
driver = await FlutterDriver.connect();
});

tearDownAll(() async {
if (driver != null) {
  driver.close();
}
});

test('T001loginAsDriverAndVerifyThatDriverIsLogedInTest', () async {
  some_code...
});
});

现在,我想制作新的测试文件(例如login_warning.dart),并能够通过调用单个配置文件(login.dart)来启动两个测试.那有可能吗?

Now I want to make new test file (e.g login_warning.dart) and be able to start both tests by calling single config file (login.dart). Is that even possible?

推荐答案

是的,可以使用相同的配置"运行多个测试"文件.

Yes, running multiple "test" files with the same "config" is possible.

在通俗易懂的行话中,您的配置文件是您的 target ,而您的测试文件是您的 driver .您的目标始终是login.dart,但是您有两个驱动程序login_test.dartlogin_warning.dart.

In the flutter jargon, your config file is your target and your test file is your driver. Your target is always login.dart but you have the two drivers login_test.dart and login_warning.dart.

使用flutter drive命令,您可以指定targetdriver.

With the flutter drive command, you can specify the target as well as the driver.

因此,要运行两个驱动程序,只需执行以下命令

So in order to run both drivers, simply execute the following commands

flutter drive --target=test_driver/login.dart --driver=test_driver/login_test.dart
flutter drive --target=test_driver/login.dart --driver=test_driver/login_warning.dart

这首先执行login_test.dart,然后执行login_warning.dart驱动程序.

This executes first the login_test.dart and then the login_warning.dart driver.

这篇关于我可以在Flutter中使用一个配置文件运行多个集成测试吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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