-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Add Basic Junit Tests to some plugins #4108
Conversation
public class GoogleSignInTest { | ||
@Test | ||
public void aTest() { | ||
assertEquals(2, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there something from the plugin implementation that we could test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could, but I think this would require me to change the code of each plugin to add a meaningful test. The Java code in most of these plugins weren't designed to be tested and adding a test would require making a method/field public and mocking stuff. I'll add some arbitrary tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stuartmorgan any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary goal is to have the structure in place so that we can point PR authors to a file to add tests to, rather than saying "you need to add a test file in the right place, then update the build, etc."
A meaningful test is obviously better than not since it provides more of an example to follow, but I'm fine with just having a placeholder in the interests of getting the basic test harness infrastructure in place everywhere. If we do placeholders we should:
- Clearly comment that it's a placeholder until some real tests are in place (I know it should be obvious, but a first-time contributor could be confused).
- Ideally have the placeholder do something with the plugin (e.g., in the corresponding iOS changes Jenn had the placeholder test just instantiate the plugin; could we do something similar?). That guarantees that we don't have, say, linking or import issues that someone trying to use it for the first time would immediately hit.
once the test is updated, we also need to enable these tests in CI |
Isn't that what https://github.com/flutter/plugins/blob/master/.cirrus.yml#L154 is doing? If not, what are the extra steps to enable them? |
@stuartmorgan ah, nvm. I thought it required a manual line.
|
|
||
public class SharedPreferencesTest { | ||
@Test | ||
public void initPlugin() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to change it to initPluginDoesNotThrow
?
...layer/video_player/android/src/test/java/io/flutter/plugins/videoplayer/VideoPlayerTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % comment
…utter/plugins/videoplayer/VideoPlayerTest.java Co-authored-by: Emmanuel Garcia <[email protected]>
* upstream_v0_8_1+3: (99 commits) [image_picker] Fixed IOException when cache directory is removed (flutter#4117) [in_app_purchase] Fix app exceptions caused by missing App Store receipt (flutter#4096) Add Basic Junit Tests to some plugins (flutter#4108) [image_picker]Update example app (flutter#4103) [flutter_plugin_tools] Restructure version-check (flutter#4111) Split some Cirrus script steps (flutter#4112) [flutter_plugin_tools] Migrate java-test to new base command (flutter#4105) [flutter_plugin_tools] ignore flutter_plugin_tools when publishing (flutter#4110) [in_app_purchase] Add support for SKPaymentQueueDelegate and showPriceConsentIfNeeded (flutter#4085) [flutter_plugin_tools] release 0.3.0 (flutter#4109) Migrate command, add failure test, remove skip (flutter#4106) Don't install cocoapods; use the version in the image (flutter#4104) [flutter_plugin_tools] Migrate analyze to new base command (flutter#4084) Add release status badge to README (flutter#4102) Build all iOS example apps on current Flutter stable (flutter#4101) [url_launcher] Fix test button check for iOS 15 (flutter#4088) Update .ci.yaml documentation link (flutter#4090) [image_picker] Updated pickImage and pickVideo docs to expose the possible errors that can be thrown (flutter#4089) [flutter_plugin_tools] `publish-plugin` check against pub to determine if a release should happen (flutter#4068) [webview_flutter] Suppress iOS 9 deprecation warnings (flutter#4100) ... # Conflicts: # packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m
flutter/flutter#83358
Pre-launch Checklist
dart format
.)[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.