简体   繁体   English

一个接一个地运行相同的颤振测试。 1成功1失败

[英]Running the same flutter test after each other. 1 succeeds and 1 fails

Im starting with creating Flutter tests and running into a problem with 2 tests that are exactly the same, but only 1 succeeds.我从创建 Flutter 测试开始,遇到了 2 个完全相同的测试的问题,但只有 1 个成功。

Gist: https://gist.github.com/Mooibroek/bd6c02e5b56e4b03409ee1839a2e0b23要点: https ://gist.github.com/Mooibroek/bd6c02e5b56e4b03409ee1839a2e0b23

The second one fails with this error:第二个失败并出现此错误:

The following TestFailure object was thrown running a test:
  Expected: exactly one matching node in the widget tree
  Actual: ?:<zero widgets with widget matching predicate (Closure: (dynamic) => bool) (ignoring
  offstage widgets)>
   Which: means none were found but one was expected

When the exception was thrown, this was the stack:
#4      main.<anonymous closure> (file:///Users/nicepants/Projects/flutter/generic_flutter/test/register_test.dart:38:5)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:108:25)

Line 38 is the line where we assert if the button is found.第 38 行是我们断言是否找到按钮的行。 I added most of the related code in the GIST, let me know if you need more.我在 GIST 中添加了大部分相关代码,如果您需要更多,请告诉我。

Is it in any way possible that there is some hidden state left from the previous test?是否有可能从之前的测试中留下一些隐藏状态? Or is this not suppose to work.或者这不应该工作。

I'm using a similar setup where I just duplicated my testWidgets() .我正在使用类似的设置,我刚刚复制了我的testWidgets() There shouldn't be ay issues with referencing the same Widget on the test since the second testWidgets() initializes a new MyApp on tester.pumpWidget() .由于第二个testWidgets()tester.pumpWidget() () 上初始化了一个新的 MyApp,所以在测试中引用同一个 Widget 应该没有问题。 Though I'm using integration_test and flutter driver to launch my tests.虽然我正在使用integration_testflutter driver来启动我的测试。

The tests should run the app on the emulator or physical device if you're using one.如果您使用的是模拟器或物理设备,测试应该在模拟器或物理设备上运行应用程序。 Check if the screen that appears on the second testWidgets() is correct.检查第二个testWidgets()上出现的屏幕是否正确。 Tap the expected Widget to be found on screen in the emulator.在模拟器的屏幕上点击预期的小部件。 This should show logs on how the tapped Widget can be found in the test.这应该显示有关如何在测试中找到被点击的 Widget 的日志。 The logs should look similarly to this日志应该与此类似

测试日志

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用构造函数参数来相互评估最终值。 颤动/飞镖 - Use constructor arguments to evaluate final values depending on each other. Flutter / Dart 在 Animation 中为 2 个文本小部件依次创建幻灯片的最佳方法是什么。 FLUTTER? - What is the best way to create Slide in Animation for 2 text widgets sequentially one after the other. FLUTTER? 断言在 Web 版本上失败,但在 iOS Flutter 上成功 - Assertion fails on Web version, but succeeds on iOS Flutter Flutter 文件播放列表一个接一个 - Flutter play list of files after each other flutterdependOnInheritedWidgetOfExactType 在测试中失败 - flutter dependOnInheritedWidgetOfExactType fails in test 运行 flutter 医生失败 - Running flutter doctor fails 添加“ local_auth”库后,Flutter应用程序运行失败 - Flutter Application fails running after adding “local_auth” library 我想在彼此下面有 4 个容器。 但是当我这样写时,红色容器在其他容器之上 - I want to have 4 containers under each other. But the red container is above the others when I write it like this Flutter如何一个接一个地更新小部件而不是同时更新 - Flutter How to update widgets one after the other instead of at the same time 使用 CI 运行自动化 Flutter 测试 - Running automated Flutter test with CI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM