新的INTEGRATION_TEST程序包仅显示&Quot;Test Starting.[Android] [英] New integration_test package just shows "Test starting..." [Android]
本文介绍了新的INTEGRATION_TEST程序包仅显示&Quot;Test Starting.[Android]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将旧的颤振驱动程序测试迁移到新的integration_test package。 我几乎复制了example project中的所有内容,并在本地执行了示例项目的集成测试。这就像预期的一样,我能够看到应用程序的用户界面。 但我自己的应用程序在闪屏显示后只显示紫色的"测试开始."(&q;Test Starting)。
example_test.dart:
void main() {
group('My-App', () {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as IntegrationTestWidgetsFlutterBinding;
testWidgets('Tap on SkipAuthentication', (tester) async {
app.main();
await binding.traceAction(() async {
await tester.pumpAndSettle();
await Future.delayed(Duration(seconds: 5));
final fab = find.byKey(ValueKey(WidgetKeys.authenticationScreenKeys.skipAuthenticationButton));
await tester.tap(fab);
await tester.pumpAndSettle();
});
});
integration_driver.dart:
Future<void> main() async {
integrationDriver();
}
我发现,如果我不启动tester.ump pWidget(),它会显示我传递给方法的Widget,但这是WidgetTest而不是集成测试。
我的猜测是,这是因为我的main函数是异步函数。 我在以前的颤振驾驶测试中也需要this workaround来等待第一帧。 但是我想不出如何使用新的INTEGRATION_TEST包来实现这一点。
希望您能帮助我。
推荐答案
我也为此苦苦思索了几个小时,终于找到了答案。
您的问题是不要使用await tester.pumpWidget(MyApp())
您的测试如下:
void main() {
testWidgets('Tap on SkipAuthentication', (tester) async {
app.main(); // <--- You call app.main() - This Flutter Driver style, but not integration test style
await binding.traceAction(() async {
await tester.pumpAndSettle();
await Future.delayed(Duration(seconds: 5));
final fab = find.byKey(ValueKey(WidgetKeys.authenticationScreenKeys.skipAuthenticationButton));
await tester.tap(fab);
await tester.pumpAndSettle();
});
});
您需要按如下方式更改测试:
void main() {
testWidgets('Tap on SkipAuthentication', (tester) async {
await tester.pumpWidget(MyApp()); // You need to call await tester.pumpWidget();
await tester.pump(const Duration(seconds: 1));
final fab = find.byKey(ValueKey(WidgetKeys.authenticationScreenKeys.skipAuthenticationButton));
await tester.tap(fab);
await tester.pump();
});
}
这篇关于新的INTEGRATION_TEST程序包仅显示&Quot;Test Starting.[Android]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文