text stringlengths 1 372 |
|---|
<topic_start> |
types of plugin tests |
to see examples of each of these types of tests, you can |
create a new plugin from the plugin template |
and look in the indicated directories. |
dart unit tests and widget tests. |
these tests allow you to test the dart portion of your plugin |
just as you would test the dart code of a non-plugin package. |
however, the plugin’s native code won’t be loaded, |
so any calls to platform channels need to be mocked in tests. |
see the test directory for an example. |
dart integration tests. |
since integration tests run in the context of a |
flutter application (the example app), |
they can test both the dart and native code, |
as well as the interaction between them. |
they are also useful for unit testing web implementation |
code that needs to run in a browser. |
these are often the most important tests for a plugin. |
however, dart integration tests can’t interact with native UI, |
such as native dialogs or the contents of platform views. |
see the example/integration_test directory for an example. |
native unit tests. |
just as dart unit tests can test the dart portions |
of a plugin in isolation, native unit tests can |
test the native parts in isolation. |
each platform has its own native unit test system, |
and the tests are written in the same native languages |
as the code it is testing. |
native unit tests can be especially valuable |
if you need to mock out APIs wrapped by your plugin code, |
which isn’t possible in a dart integration test. |
you can set up and use any native test frameworks |
you are familiar with for each platform, |
but the following are already configured in the plugin template: |
android: |
JUnit tests can be found in android/src/test/. |
iOS and macOS: |
XCTest tests can be found in example/ios/RunnerTests/ |
and example/macos/RunnerTests/ respectively. |
these are in the example directory, |
not the top-level package directory, |
because they are run via the example app’s project. |
linux and windows: |
GoogleTest tests can be found in linux/test/ |
and windows/test/, respectively. |
other types of tests, which aren’t currently pre-configured |
in the template, are native UI tests. |
running your application under a native UI testing framework, |
such as espresso or XCUITest, |
enables tests that interact with both native and flutter UI elements, |
so can be useful if your plugin can’t be tested without |
native UI interactions. |
<topic_end> |
<topic_start> |
running tests |
<topic_end> |
<topic_start> |
dart unit tests |
these can be run like any other flutter unit tests, |
either from your preferred flutter IDE, |
or using flutter test. |
<topic_end> |
<topic_start> |
integration tests |
for information on running this type of test, check out the |
integration test documentation. |
the commands must be run in the example directory. |
<topic_end> |
<topic_start> |
native unit tests |
for all platforms, you need to build the example |
application at least once before running the unit tests, |
to ensure that all of the platform-specific build |
files have been created. |
android JUnit |
if you have the example opened as an android project |
in android studio, you can run the unit tests using |
the android studio test UI. |
to run the tests from the command line, |
use the following command in the example/android directory: |
iOS and macOS XCTest |
if you have the example app opened in xcode, |
you can run the unit tests using the xcode test UI. |
to run the tests from the command line, |
use the following command in the example/ios (for iOS) |
or example/macos (for macOS) directory: |
for iOS tests, you might need to first open |
runner.xcworkspace in xcode to configure code signing. |
linux GoogleTest |
to run the tests from the command line, |
use the following command in the example directory, |
replacing “my_plugin” with your plugin project name: |
if you built the example app in release mode rather than |
debug, replace “debug” with “release”. |
windows GoogleTest |
if you have the example app opened in visual studio, |
you can run the unit tests using the visual studio test UI. |
to run the tests from the command line, |
use the following command in the example directory, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.