question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testWidgets within a `group`

See original GitHub issue

Steps to Reproduce

  1. Create a test file
  2. Create a group declaration. e.g. group("MyGroupOfWidgetTests", () { /* Widget Tests here */ });
  3. Put some widget tests within the group
  4. Run the tests
  5. PROBLEMS: - Tests are nested an extra level, making them a bit more difficult to read - One cannot run testWidgets tests individually within a group, only the group itself.

Workarounds

Remove the group and move tests to their own file. When tests are out of the group, they are displayed properly and can be run individually.

Screenshots

screenshot 2017-07-29 00 03 19 screenshot 2017-07-29 00 05 47

Version info

[✓] IntelliJ IDEA Community Edition (version 2017.2) • Flutter plugin version 16.0 • Dart plugin version 172.3317.48

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
DanTupcommented, May 26, 2018

Ok, I did some more digging and found a comment in the PR about it:

https://github.com/flutter/flutter/pull/3622#discussion_r61632399

as discussed in person (but recorded here for posterity), I’m using the group because I need to be able to tear down state when the test times out, and try/finally blocks in the _runTest won’t run if the test times out. I’ve filed dart-lang/test#426 to track this.

That issue was closed as a dupe of https://github.com/dart-lang/test/issues/93 which appears to have been implemented; so I’ll open an issue in flutter to see if we can change this. (Edit: https://github.com/flutter/flutter/issues/17932)

(I presume the IntelliJ code is safe if the group disappears, since it’s handling other cases where this doesn’t occur, like bare test()s?).

1reaction
pqcommented, Jul 29, 2017

Thanks for this report. I have a good idea of what’s happening and will take a look.

Any other feedback on the test integration would be greatly appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to `setUp` a `WidgetTester` for Multiple Tests in Flutter
And then you should only have a single call to testWidgets(..) ... Use it first in the main method, outside of group and...
Read more >
testWidgets function - flutter_test library - Flutter - Dart API docs
Runs the callback inside the Flutter test environment. Use this function for testing custom StatelessWidgets and StatefulWidgets. The callback can be ...
Read more >
A Deep Dive Into Widget Testing in Flutter : Part I (testWidgets ...
The usual practice is to write several groups of tests that test out various functionalities of the widget such as verifying the visual ......
Read more >
focus_traversal_test.dart - Google Git
testWidgets ('Move focus to next/previous node while skipping nodes in policy', ... when no focusable is available in a group', (WidgetTester tester) async...
Read more >
How to use Alchemist for Flutter golden tests
Each test case is contained in a testWidgets function which uses tester.pumpWidget to load the widget under test. Any desired interactions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found