Skip to content

Commit f4ce37d

Browse files
authored
Add mockito links to testing page (#1925)
Also did a bit of copy editing. Fixes #1912.
1 parent e8aab82 commit f4ce37d

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/docs/testing/index.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22
title: Testing Flutter apps
33
---
44

5-
The more features your app has, the harder it is to test it manually. A
6-
good set of automated tests help you make sure your app performs
5+
The more features your app has, the harder it is to test manually.
6+
Automated tests help ensure that your app performs
77
correctly before you publish it, while retaining your feature and bug fix
88
velocity.
99

10-
There are many kinds of automated testing. These are summarized below:
10+
Automated testing falls into a few categories:
1111

1212
- A _unit test_ tests a single function, method, or class. External dependencies
13-
of the unit under test are generally mocked out using, for example,
14-
[`package:mockito`](https://github.com/dart-lang/mockito).
15-
Unit tests generally do not read from/write to disk, render to screen and do
16-
not receive user actions from outside the process running the test. The goal
13+
of the unit under test are generally [mocked out](/cookbook/testing/mocking).
14+
Unit tests generally don't read from or write to disk, render to screen,
15+
or receive user actions from outside the process running the test. The goal
1716
of a unit test is to verify the correctness of a unit of logic under a
1817
variety of conditions.
1918
- A _widget test_ (in other UI frameworks referred to as _component test_) tests
@@ -41,19 +40,20 @@ different kinds of tests:
4140
|----------------------|--------|--------|-------------|
4241
| **Confidence** | Low | Higher | Highest |
4342
| **Maintenance cost** | Low | Higher | Highest |
44-
| **Dependencies** | Few | More | Lots |
43+
| **Dependencies** | Few | More | Most |
4544
| **Execution speed** | Quick | Slower | Slowest |
4645
{:.table.table-striped}
4746

48-
**Tip**: As a rule of thumb a well-tested app has a very high number of unit
49-
and widget tests, tracked by [code coverage](https://en.wikipedia.org/wiki/Code_coverage),
50-
and a good number of integration tests covering all the important usage
51-
scenarios.
47+
{{site.alert.tip}}
48+
A well-tested app has many unit and widget tests,
49+
tracked by [code coverage](https://en.wikipedia.org/wiki/Code_coverage),
50+
plus enough integration tests to cover all the important use cases.
51+
{{site.alert.end}}
5252

5353

5454
## Unit testing
5555

56-
Some Flutter libraries, such as `dart:ui`, are not available in the standalone
56+
Some Flutter libraries, such as `dart:ui`, aren't available in the standalone
5757
Dart VM that ships with the default Dart SDK. The `flutter test` command lets
5858
you run your tests in a local Dart VM with a headless version of the Flutter
5959
Engine, which supplies these libraries. Using this command you can run any test,
@@ -87,15 +87,20 @@ dev_dependencies:
8787
sdk: flutter
8888
```
8989
90-
(This is needed even if your test does not itself explicitly import
91-
`flutter_test`, because the test framework itself uses it behind the
92-
scenes.)
90+
{{site.alert.note}}
91+
The dev dependency on `flutter_test` is required even if
92+
your test doesn't explicitly import `flutter_test`,
93+
because the test framework uses `flutter_test` behind the scenes.
94+
{{site.alert.end}}
9395

9496
To run the test, run `flutter test test/unit_test.dart` from your
9597
project directory (not from the `test` subdirectory).
9698

9799
To run all your tests, run `flutter test` from your project directory.
98100

101+
For information on how to create mock services, see
102+
[Mock dependencies using Mockito](/cookbook/testing/mocking).
103+
99104

100105
## Widget testing
101106

@@ -323,12 +328,11 @@ but for the `_test` suffix in it.
323328

324329
## Continuous integration and testing
325330

326-
For information on continuous deployment and testing, see
331+
For information on continuous deployment and testing, see the following:
327332

328333
* [Continuous Delivery using fastlane with Flutter](/docs/deployment/fastlane-cd/)
329334
* [Test Flutter apps on Travis](https://medium.com/flutter-io/test-flutter-apps-on-travis-3fd5142ecd8c)
330-
* Test Flutter apps with [GitLab
331-
CI](https://docs.gitlab.com/ee/ci/README.html#doc-nav). You'll
332-
need to create and configure a `.gitlab-ci.yml` file. You can [find an
335+
* [GitLab Continuous Integration (GitLab CI/CD](https://docs.gitlab.com/ee/ci/README.html#doc-nav).
336+
You'll need to create and configure a `.gitlab-ci.yml` file. You can [find an
333337
example](https://raw.githubusercontent.com/brianegan/flutter_redux/master/.gitlab-ci.yml)
334338
in the [flutter_redux library](https://github.com/brianegan/flutter_redux).

0 commit comments

Comments
 (0)