weixin_39881760
weixin_39881760
2021-01-12 16:09

Flutter Support

With the up and coming Flutter.io, some apps may be 'hybrid' with both native and Flutter UI scenarios to support and test. Curious if anyone has thought about EarlGrey in this world and the support for bringing visibility of both worlds into the library.

该提问来源于开源项目:google/EarlGrey

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

9条回答

  • weixin_39900023 weixin_39900023 4月前

    FlutterDriver is the recommended way for writing Flutter app UI tests.

    https://flutter.io/docs/testing

    点赞 评论 复制链接分享
  • weixin_39958911 weixin_39958911 4月前

    We are working to support the Flutter use-case. Because of the A11Y bindings that flutter provides, EG 2 (tested) worked fine locating and interacting with the elements however there are major synchronization gaps which makes some tests as much as 90% flaky. We will be working with them to add proper synchronization support next quarter.

    点赞 评论 复制链接分享
  • weixin_39900023 weixin_39900023 4月前

    will we be able to use EarlGrey 2 from Dart?

    点赞 评论 复制链接分享
  • weixin_39958911 weixin_39958911 4月前

    That's still being debated. However, you should be able to do the opposite: Use EG2 to test all of Flutter hybrid apps from within XCTest (swift or objc)

    点赞 评论 复制链接分享
  • weixin_39900023 weixin_39900023 4月前

    That's still being debated. However, you should be able to do the opposite: Use EG2 to test all of Flutter hybrid apps from within XCTest (swift or objc)

    And then duplicate the tests on Android using Espresso? 🤔

    I think Flutter devs would prefer to stay in Dart to realize the cross platform benefit. It's similar to the use case of detox for react native.

    点赞 评论 复制链接分享
  • weixin_39881760 weixin_39881760 4月前

    Thanks for the update and discussion, much appreciated.

    When the app flow moves between native and flutter views, something 'all inclusive' would be ideal. Be it in Dart or supported in EarlGrey/Espresso, or all of the above. EarlGrey being more ideal for an app just starting to integrate with Flutter, and Flutter driver ideal for a dominantly Flutter built app. It seems the Flutter test driver is just as blind to the native UI right now. Any angle of attack on this is bound to be a fun one I think.

    点赞 评论 复制链接分享
  • weixin_39530288 weixin_39530288 4月前

    I agree with the sentiment but we have to look at the use cases.

    If your app is mostly Flutter, you likely want to write Flutter Driver tests. Just like your code moves away from ObjC/Swift/Kotlin/Java to Dart, your tests should follow. However, we (Flutter team) acknowledge that there are a lot of use cases where people will still maintain a significant portion of native code along with Flutter code. In that scenario, it is highly likely that you already have native tests so having those tests cover both Native and Flutter portion of the app is the natural way to go.

    The only thing that's not on the roadmap is having Flutter Driver drive native apps. Having said that, there are already frameworks that combine different technologies to afford x-platform testing for mobile apps (e.g. http://appium.io/).

    点赞 评论 复制链接分享
  • weixin_39900023 weixin_39900023 4月前

    there are already frameworks that combine different technologies to afford x-platform testing for mobile apps (e.g. http://appium.io/).

    As an appium developer, I'm confident it's not a fit for Flutter. Maybe you could click a button, however without solving the sync issues it's not going to be stable. Appium has the same issue with react native apps.

    In that scenario, it is highly likely that you already have native tests so having those tests cover both Native and Flutter portion of the app is the natural way to go.

    I'm curious to hear specific examples of users adopting a cross platform technology who then want to write UI tests twice, once per platform. When companies are adopting react native, they'd like to gain the developer productivity win by writing tests in JavaScript for the entire app (see detox).

    At Instructure, when we adopted react native, it was a natural choice to try and write tests in JavaScript. Even though we had an existing native app with UI tests, there was value in being able to write UI tests once and in a common language (JavaScript) for both Android/iOS. Unfortunately react native as a technology has issues and we went back to native development.

    The only thing that's not on the roadmap is having Flutter Driver drive native apps

    I guess my feedback is that should be on the roadmap, and makes more sense than writing ObjC/Swift/Kotlin/Java tests for Flutter UI. Otherwise Flutter testing will be a mix of 3 different approaches (espresso, EarlGrey, Flutter Driver) in various languages instead of simply Dart + Flutter Driver.

    If Flutter Driver solved the native automation problem by wrapping EarlGrey/Espresso as detox has done, I'd expect native apps to adopt it who aren't even using Flutter. 🙂

    点赞 评论 复制链接分享
  • weixin_39900023 weixin_39900023 4月前

    Cool. Thanks for the insight. It'll be interesting to see how this evolves in the future.

    点赞 评论 复制链接分享

相关推荐