赛派号

笔记本电脑回收多少钱一台 Testing Flutter apps

Testing Flutter apps

Learn more about the different types of testing and how to write them.

The more features your app has, the harder it is to test manually. Automated tests help ensure that your app performs correctly before you publish it, while retaining your feature and bug fix velocity.

infoNote

For hands-on practice of testing Flutter apps, see the How to test a Flutter app codelab.

Automated testing falls into a few categories:

A unit test tests a single function, method, or class. A widget test (in other UI frameworks referred to as component test) tests a single widget. An integration test tests a complete app or a large part of an app.

Generally speaking, a well-tested app has many unit and widget tests, tracked by code coverage, plus enough integration tests to cover all the important use cases. This advice is based on the fact that there are trade-offs between different kinds of testing, seen below.

TradeoffUnitWidgetIntegration ConfidenceLowHigherHighest Maintenance costLowHigherHighest DependenciesFewMoreMost Execution speedQuickQuickSlow Unit tests #

A unit test tests a single function, method, or class. The goal of a unit test is to verify the correctness of a unit of logic under a variety of conditions. External dependencies of the unit under test are generally mocked out. Unit tests generally don't read from or write to disk, render to screen, or receive user actions from outside the process running the test. For more information regarding unit tests, you can view the following recipes or run flutter test --help in your terminal.

infoNote

If you're writing unit tests for code that uses plugins and you want to oid crashes, check out Plugins in Flutter tests. If you want to test your Flutter plugin, check out Testing plugins.

Recipes # Introduction to unit testing Mock dependencies using Mockito Widget tests #

A widget test (in other UI frameworks referred to as component test) tests a single widget. The goal of a widget test is to verify that the widget's UI looks and interacts as expected. Testing a widget involves multiple classes and requires a test environment that provides the appropriate widget lifecycle context.

For example, the Widget being tested should be able to receive and respond to user actions and events, perform layout, and instantiate child widgets. A widget test is therefore more comprehensive than a unit test. However, like a unit test, a widget test's environment is replaced with an implementation much simpler than a full-blown UI system.

Recipes # Introduction to widget testing Find widgets using finders Handling scrolling in widget tests Tap, drag, and enter text in widget tests Test different orientations Integration tests #

An integration test tests a complete app or a large part of an app. The goal of an integration test is to verify that all the widgets and services being tested work together as expected. Furthermore, you can use integration tests to verify your app's performance.

Generally, an integration test runs on a real device or an OS emulator, such as iOS Simulator or Android Emulator. The app under test is typically isolated from the test driver code to oid skewing the results.

For more information on how to write integration tests, see the integration testing page.

Recipes # Integration testing concepts Measure performance with an integration test Continuous integration services #

Continuous integration (CI) services allow you to run your tests automatically when pushing new code changes. This provides timely feedback on whether the code changes work as expected and do not introduce bugs.

For information on running tests on various continuous integration services, see the following:

Continuous delivery using fastlane with Flutter Test Flutter apps on Appcircle Test Flutter apps on Tris Test Flutter apps on Cirrus Codemagic CI/CD for Flutter Flutter CI/CD with Bitrise Was this page's content helpful?

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至lsinopec@gmail.com举报,一经查实,本站将立刻删除。

上一篇 没有了

下一篇没有了