Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[url_launcher] Migrate unit tests to NNBD #3657

Merged

Conversation

stuartmorgan-g
Copy link
Contributor

Replaces the problematic Mockito mock with a manual mock that handles
null and non-null types correctly.

Pre-launch Checklist

  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

Replaces the problematic Mockito mock with a manual mock that handles
null and non-null types correctly.

Removes the unit test of the example app, since it's not adding any
actual coverage.
@stuartmorgan-g stuartmorgan-g force-pushed the url-launcher-tests-nnbd branch from f09b300 to 8ccaca4 Compare March 2, 2021 16:39
mock.canLaunch('http://example.com/foobar'),
mock.launch(
'http://example.com/foobar',
mock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to migrate away from "when...` in mockito and introduce our own mocks? mockito already migrated to stable we should be able to just use it with nnbd, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we prefer auto-gen or manual? The doc mentioned autogen is recommended and I see that you manually generated the mocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Mockito generation adds a bunch more moving pieces; it didn't seem worth adding that extra complexity for a simple class with a couple of methods. There may be cases where we want to do it, but if it's simple to just start from Fake and build manually that seems easier.

This one is probably borderline since it's doing real mock validation rather than just faking; in a number of other cases we were using Mockito to make fakes, not actual mocks. We may want to give it a try for the remaining unit tests that need conversion and compare (or I can try it with this one if you'd like).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try with android_intent

Copy link
Contributor

@cyanglaz cyanglaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stuartmorgan-g stuartmorgan-g added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Mar 2, 2021
@fluttergithubbot
Copy link

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite submit-queue has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Mar 2, 2021
@stuartmorgan-g stuartmorgan-g merged commit b90e42b into flutter:master Mar 2, 2021
@stuartmorgan-g stuartmorgan-g deleted the url-launcher-tests-nnbd branch March 2, 2021 22:00
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2021
NickalasB added a commit to NickalasB/plugins that referenced this pull request Mar 3, 2021
* master:
  Adopt Xcode 12 for podspec lints (flutter#3653)
  Run static analyzer during xctest (flutter#3667)
  [google_maps_flutter_web] update min flutter sdk version to 1.20.0 (flutter#3662)
  [image_picker] Run CocoaPods iOS tests in RunnerUITests target (flutter#3663)
  [webview_flutter] Run CocoaPods iOS tests in RunnerUITests target (flutter#3664)
  [device_info] Enable NNBD for unit test (flutter#3658)
  remove unused plugin (flutter#3661)
  [android_intent] move unit test to nullsafety (flutter#3659)
  [url_launcher] Migrate unit tests to NNBD (flutter#3657)
  [share] Migrate unit tests to null-safety. (flutter#3660)
  [connectivity_for_web] Migration to null-safety. (flutter#3652)
  [camera] Stable release for null safety. (flutter#3641)
  [in_app_purchase] fix plugin version (flutter#3654)
  Move plugin tool tests over (flutter#3606)
  [in_app_purchase] migrate playing billing library to v3 (flutter#3636)
  Update plugin_platform_interface min version (flutter#3650)

# Conflicts:
#	packages/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants