Skip to content

Allow running non-widget tests #1421

Closed
flutter/flutter
#27532

Description

@xster

We're supporting widget tests but we should also support test besides testWidgets

Activity

  1. DanTup commented on Jan 24, 2019

    @DanTup
    Member

    As far as I'm aware, this all already works! :)

    screenshot 2019-01-24 at 8 59 06 am

    If you're seeing issues, can you provide more info on what your project/code looks like and where you're seeing the failure?

  2. added
    awaiting infoRequires more information from the customer to progress
    on Jan 24, 2019
  3. xster commented on Jan 30, 2019

    @xster
    Author

    I only reproduced it in this case. flutter/flutter#27002. Which isn't really supported anyway. Closing

  4. DanTup commented on Jan 30, 2019

    @DanTup
    Member

    If you have a small repro, I'd be interested to know went wrong in the VS Code plugin. Even if the error messages are obscure, that shouldn't cause any bad behaviour in the test runner. Maybe there are edge cases not being handled correctly?

  5. xster commented on Jan 31, 2019

    @xster
    Author

    Actually maybe it doesn't work. Try https://github.com/flutter/flutter/blob/master/packages/flutter/test/rendering/editable_test.dart. F5 works on that file but they aren't per-method debuggable in the editor UI.

  6. reopened this on Jan 31, 2019
  7. DanTup commented on Jan 31, 2019

    @DanTup
    Member

    Ok, I think I figured this out... This feature works using the UNIT_TEST_TEST items in the OUTLINE notification. It seems like in the file above, we only get a UNIT_TEST_TEST for one test - the one that uses testWidgets, not the others (you can see the outine tree on the left here, and the code on the right):

    screenshot 2019-01-31 at 10 01 06 am

    I did some digging through the server code, and it seems that in order to be considered a test call, the method (being called) needs to:

    1. Be called test and live inside the test package
    2. Be annotated with @isTest

    It seems that testWidget is annotated with @isTest but test from flutter_test is not. I think the way to fix this would be to add the @isTest annotation to the test method inside flutter_test that is being called here. I do not know if there are any side-effects of that though :-)

  8. DanTup commented on Jan 31, 2019

    @DanTup
    Member

    I think the change may be safe, it seems like it's just a marker annotation that doesn't really do much. @scheglov maybe you can confirm - you added it to testWidget (flutter/flutter#17772) - do you expect it's safe to add this to the test function here?

  9. added and removed
    awaiting infoRequires more information from the customer to progress
    on Jan 31, 2019
  10. scheglov commented on Jan 31, 2019

    @scheglov

    It looks like a copy of package:test, so yes, I think test and group functions also should be marked as @isTest and @isTestGroup.

  11. DanTup commented on Feb 5, 2019

    @DanTup
    Member

    I've opened a PR at flutter/flutter#27532.

  12. added a commit that references this issue on Feb 5, 2019
  13. DanTup commented on Feb 5, 2019

    @DanTup
    Member

    Fixed in Flutter master, thanks for the report!

  14. added a commit that references this issue on Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions