在Flutter中打开集成测试中的深层链接
我正在尝试运行一个集成测试,该测试高度依赖于用户单击他在电子邮件中收到的魔术链接。到目前为止我还没有找到一种方法来做到这一点。我遇到了 Process.run,但它似乎应该在集成测试开始之前运行,并且我需要在测试期间执行它。
任何有关 iOS 或 Android 的帮助将不胜感激。
I'm trying to run an integration test which is highly dependent on the user clicking a magic link he got in his email. So far I failed to find a way of doing that. I came across Process.run
but it seems like it should be run before the integration test starts and I need to do it during the test.
Any help with either iOS or Android will be highly appreciated. ????
This is the code I tried so far to work on iOS but Process.run
ends with ProcessException: No such file or directory
:
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('login test', (WidgetTester tester) async {
app_sandbox.main();
await tester.pumpAndSettle(Duration(seconds: 5));
expect(find.text('foo'), findsOneWidget);
await Process.run('xcrun', [
'simctl',
'openurl',
'7D6DEC47-C1E2-4F18-A38B-7B4C17558172',
'https://myDeepLink/sign-in',
]);
await tester.pumpAndSettle();
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能只适用于 flutter_driver,
不适用于integration_test 的 testWidgets
,我收到此错误:
this might only work with flutter_driver
not with testWidgets of integration_test
there I got this error:
这是一个老问题,但我想把它留在这里供其他需要它的人使用。您可以在集成测试中通过 WidgetsFlutterBinding 发送到平台的链接,并且您正在使用的任何路由系统都应该拾取该链接,然后进行适当的处理。
这是我为集成测试制作的帮助程序,用于在测试期间随时发送链接
This is an old issue, but I wanted to leave this here for anyone else that needs it. You can send a link to the platform through the
WidgetsFlutterBinding
in an integration test, and it should be picked up by whatever routing system you are using then handled appropriately.This is the helper I made for integration tests to send a link at any point during a test