Flutter-intellij: testWidgets within a `group`

Created on 29 Jul 2017  ·  9Comments  ·  Source: flutter/flutter-intellij

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

bug topic-testing

All 9 comments

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!

Thanks for the response!

Overall it's worked very well. I really prefer running tests from within my IDE for a fast red / green / refactor / debug loop, so these updates are a great addition :D

Good deal! Thanks for the follow-up and glad it's generally working well for you. I have a bead on what's up with the synthetic '-' test groups and hope to have a fix for the next release.

Cheers! 🍻

Good deal! Thanks for the follow-up and glad it's generally working well for you. I have a bead on what's up with the synthetic '-' test groups and hope to have a fix for the next release.

Cheers! 🍻

@pq I just discovered this problem working on Code -> https://github.com/dart-lang/test/issues/836

I was going to open an issue questionning the - groups that are being added. Do you happen to know if there's a good reason for them? Am I better also working around this, or should we try to get flutter test changed in some way?

@DanTup : great question. Honestly I'm not sure. It certainly would be more elegant of this worked a little better lower down but I'm not sure if it makes sense to push on it. Nor do I know what it would involve... Let me know if you dig any further!

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?).

Good find @DanTup! I think the IntelliJ code should just solider on w/ the change but keep me in the loop so I can test if/when it lands. And assuming it does we can do a little cleanup as well which would be great.

Cheers!

It looks like this has regressed.

When I right-click on a member of a group, I get a menu with just "Nothing here" in it, so I can't run it individually. Copy/pasting the name of the test from the code into the run configuration works, so it's something to do with discovering the test name to run.

Screenshot from 2019-09-05 14-30-15

Was this page helpful?
0 / 5 - 0 ratings