小部件测试,使用CircularProgressIndicator测试按钮

时间:2020-10-06 18:09:56

标签: flutter testing widget-test-flutter

我有两个测试,单击按钮后,我想测试CircularProgressIndicator是否会出现在按钮上。 问题是在点击和pr: branches: include: - '*' pool: vmImage: 'macos-latest' stages: - stage: CI displayName: 'Continues build' condition: eq(variables['Build.Reason'], 'PullRequest') jobs: - job: C1 steps: - script: echo "Hello $(System.StageName)" - stage: Test displayName: 'Building for Test' condition: ne(variables['Build.Reason'], 'PullRequest') jobs: - job: T1 steps: - script: echo "Hello $(System.StageName)" - stage: Stage displayName: 'Building for Stage' condition: ne(variables['Build.Reason'], 'PullRequest') jobs: - job: S1 steps: - script: echo "Hello $(System.StageName)" 之后,找不到导致测试失败的CircularProgressIndicator,我尝试了tester.pump()并添加了pumpAndSettle()但出现了相同的错误< / p>

这很奇怪,因为在我将flutter sdk更新到1.22.0,升级我的flutterFire软件包并迁移以使用Android嵌入式V2之前,测试尚可。

Duration(seconds:x)

1 个答案:

答案 0 :(得分:0)

有点晚了,但我也遇到了这个问题,我发现最短的解决方法只是尝试/捕获超时错误...

try {
  await tester.pumpAndSettle();
} catch (err) {}

expect(find.byKey(financialDialogBillRequestButtonLoading), findsOneWidget);
expect(find.byKey(financialDialogBillRequestButton), findsNothing);

如果能在找到更好的解决方案之前帮助某人,那就太高兴了。