forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an integration test to plugin template example (#117062)
* Add an integration test to plugin template example Dart unit tests don't exercise host-side plugin code at all, so the example tests in the plugin template currently have very little meaningful coverage. This adds an integration test to the example app when creating a plugin, so that there's an example of how to actually test that a complete round-trip plugin call works. This is done as a separate template that's currently only used by the plugin template because I don't know what a good example for a non-plugin case would be that isn't largely just a duplicate of the widget tests. However, the integration test pre-includes conditionals around the parts that are plugin-specific so that it can more easily be expanded to other use cases later (e.g., in flutter/flutter#68818). Part of flutter/flutter#82458 * Add integration test to expected dependencies of a plugin app * Test fixes * Make an explicit test case
- Loading branch information
1 parent
b122200
commit f1d157b
Showing
8 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...r_tools/templates/app_integration_test/integration_test/plugin_integration_test.dart.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// This is a basic Flutter integration test. | ||
{{#withPlatformChannelPluginHook}} | ||
// | ||
// Since integration tests run in a full Flutter application, they can interact | ||
// with the host side of a plugin implementation, unlike Dart unit tests. | ||
{{/withPlatformChannelPluginHook}} | ||
// | ||
// For more information about Flutter integration tests, please see | ||
// https://docs.flutter.dev/cookbook/testing/integration/introduction | ||
|
||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:integration_test/integration_test.dart'; | ||
|
||
{{#withPlatformChannelPluginHook}} | ||
import 'package:{{pluginProjectName}}/{{pluginProjectName}}.dart'; | ||
{{/withPlatformChannelPluginHook}} | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
{{#withPlatformChannelPluginHook}} | ||
|
||
testWidgets('getPlatformVersion test', (WidgetTester tester) async { | ||
final {{pluginDartClass}} plugin = {{pluginDartClass}}(); | ||
final String? version = await plugin.getPlatformVersion(); | ||
// The version string depends on the host platform running the test, so | ||
// just assert that some non-empty string is returned. | ||
expect(version?.isNotEmpty, true); | ||
}); | ||
{{/withPlatformChannelPluginHook}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters