mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Bumps [go_router](https://github.com/flutter/packages/tree/main/packages) from 7.1.1 to 8.0.1. <details> <summary>Commits</summary> <ul> <li><a href="f6633b20d0"><code>f6633b2</code></a> [go_router] Update link to example for query and path parameters (<a href="https://github.com/flutter/packages/tree/main/packages/issues/3994">#3994</a>)</li> <li><a href="852acaa9f9"><code>852acaa</code></a> [in_app_pur]: Bump org.jetbrains.kotlin:kotlin-bom from 1.8.0 to 1.8.21 in /p...</li> <li><a href="7d00ea7d4b"><code>7d00ea7</code></a> [image_picker]: Bump androidx.activity:activity from 1.7.0 to 1.7.1 in /packa...</li> <li><a href="bcddb9a1f0"><code>bcddb9a</code></a> [webview_flutter] Explicitly disable ATS in example apps (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4166">#4166</a>)</li> <li><a href="3e0a170706"><code>3e0a170</code></a> Fix stale ignore: prefer_const_constructors from flutter/packages (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4154">#4154</a>)</li> <li><a href="e13b8c4338"><code>e13b8c4</code></a> [tool] Only run unit tests in Chrome for inline web (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4153">#4153</a>)</li> <li><a href="1057ab48db"><code>1057ab4</code></a> [in_app_purchase] Make the _FeatureCard constructor const in the Android exam...</li> <li><a href="d935cb0d2f"><code>d935cb0</code></a> [shared_preferences] Fix initialization race (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4159">#4159</a>)</li> <li><a href="010ba50128"><code>010ba50</code></a> [go_router] Refactors imperative APIs and browser history (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4134">#4134</a>)</li> <li><a href="e37dd83c91"><code>e37dd83</code></a> [various] Add <code>http</code> 1.0 compatibility (<a href="https://github.com/flutter/packages/tree/main/packages/issues/4147">#4147</a>)</li> <li>Additional commits viewable in <a href="https://github.com/flutter/packages/commits/go_router-v8.0.1/packages">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
testing_app
A Sample app that shows different types of testing in Flutter.
This particular sample uses the Provider package but any other state management approach would do.
Goals for this sample
Show how to perform:
- Widget Testing,
- Integration Testing,
- Performance Testing, and
- State Management Testing using the Provider package.
How to run tests
- Navigate to the project's root folder using command line and follow the instructions below.
To run tests using only the Flutter SDK:
The Flutter SDK can run unit tests and widget tests in a virtual machine, without the need of a physical device or emulator.
- To run all the test files in the
test/directory in one go, runflutter test. - To run a particular test file, run
flutter test test/<file_path>
To run tests on a physical device/emulator:
- Widget Tests:
- Run
flutter run test/<file_path>
- Run
- Integration Tests:
- Run
flutter test integration_testto run all the integration tests with a single command. - Alternatively, you can run
flutter drive --driver=integration_test/driver.dart --target=integration_test/app_test.dartto run them separately. You can also provide custom driver files with this command.
- Run
- Performance Tests:
- Run
flutter drive --driver=integration_test/perf_driver.dart --target=integration_test/perf_test.dart --profile --trace-startup- Using a physical device and running performance tests in profile mode is recommended.
- The
--trace-startupoption is used to avoid flushing older timeline events when the timeline gets long.
- Run
- State Management Tests:
- For testing state using Flutter Integration Tests
- Run
flutter drive --driver=integration_test/driver.dart --target=integration_test/state_mgmt_test.dart
- Run
- For testing state using Flutter Integration Tests
To generate test coverage report:
- Install the
lcovtool:- For MacOS, run
brew install lcov - For Linux, run
sudo apt install lcov
- For MacOS, run
- Run tests with coverage:
flutter test --coverage
- Convert
lcov.infointo readable html:- Run
genhtml coverage/lcov.info -o coverage/index
- Run
- Open
coverage/index/index.htmlin your preferred browser.
CI/CD
Note that tools like GitHub Actions can't run tests on a physical device, which is required to run integration tests. Instead, you can use Firebase Test Lab, Codemagic or any platform of your choice to do that.
Questions/issues
If you have a general question about testing in Flutter, the best places to go are:
If you run into an issue with the sample itself, please file an issue.