[英]Flutter Integration Tests Not Waiting For App To Load Before Failure
On an app I've been creating I setup some integration tests in the past and made sure they were working.在我一直在创建的应用程序上,我过去设置了一些集成测试并确保它们正常工作。 Now some months and many commits later, I am setting up GitHub actions and noticed for some reason my tests fail every time.
现在几个月和许多提交之后,我正在设置 GitHub 操作并注意到由于某种原因我的测试每次都失败。 I noticed that the app doesn't even load up at all before the tests fail, even though I use
WidgetTester tester.pumpAndSettle();
我注意到即使我使用
WidgetTester tester.pumpAndSettle();
在测试失败之前应用程序甚至根本没有加载。
Here is a sample of my code:这是我的代码示例:
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// Testing login-page UI, logging in, and moving to next screen
testWidgets(
"Integration test runner 1",
(WidgetTester tester) async {
// Wait for the app to launch, etc
app.LoginPage();
await tester.pumpAndSettle();
expect(find.byKey(ValueKey("bigTextFostering")), findsOneWidget);
}
I tried using a waitForElement helpfer function, but had the same outcome我尝试使用 waitForElement helpfer function,但结果相同
Looks like好像
await tester.pumpAndSettle(Duration(seconds: 7));
Did the trick... The only reason I have it set for 7 seconds because we have a splash screen I want to load through fully成功了吗...我将其设置为 7 秒的唯一原因是因为我们有一个启动画面,我想完全加载
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.