Skip to content

Commit 6171e00

Browse files
[espresso] Adopt code-excerpts for README (flutter#12644)
The excerpt validator (`readme_validator.dart`) only requires `<?code-excerpt?>` management for **Dart** code blocks, so the README's Java/Groovy/XML/sh snippets are left untouched. The one Dart block — the `test_driver/` script — used the deprecated `flutter_driver` `enableFlutterDriverExtension()` API, which no longer has a real, compilable counterpart in this repo now that the example app migrated to the `integration_test` package. Points the excerpt at the example's actual `test_driver/integration_test.dart` (`integrationDriver()`) instead, and updates the surrounding prose and the `./gradlew` command to match the real filename. Also drops the package's `ci_config.yaml`, whose only purpose was opting it out of that validation. Follows the same pattern as flutter#12641 ([pointer_interceptor] Adopt code-excerpts for README) and flutter#12643 ([quick_actions] Adopt code-excerpts for README). Part of flutter#102679. ## Pre-Review Checklist ## Test plan [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. **Note**: The Flutter team is currently trialing [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from `gemini-code-assist[bot]` aren't authoritative Flutter-team feedback; I'll wait for a human reviewer's guidance on which automated comments (if any) should be addressed.
1 parent e3202be commit 6171e00

7 files changed

Lines changed: 46 additions & 19 deletions

File tree

‎packages/espresso/CHANGELOG.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.4.0+26
2+
3+
* Adopts `code-excerpt` for the README's Dart driver snippet so it is
4+
validated against compilable, analyzed source, and updates it to use
5+
`integration_test`'s driver instead of the deprecated `flutter_driver`
6+
extension.
7+
* Adopts `code-excerpt` for the README's `network_security_config.xml` and
8+
`build.gradle.kts` dependencies snippets.
9+
110
## 0.4.0+25
211

312
* Bumps com.google.guava:guava from 33.5.0-android to 33.6.0-android.

‎packages/espresso/README.md‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# espresso
2+
<?code-excerpt path-base="example"?>
23

34
Provides bindings for Espresso tests of Flutter Android apps.
45

@@ -18,8 +19,8 @@ Add ```android:networkSecurityConfig="@xml/network_security_config"``` in the ``
1819

1920
Then you will need to create a `network_security_config.xml` in the `res/xml/` directory.
2021

22+
<?code-excerpt "android/app/src/debug/res/xml/network_security_config.xml (network_security_config)"?>
2123
```xml
22-
<?xml version="1.0" encoding="utf-8"?>
2324
<network-security-config>
2425
<!-- Cleartext is needed for Espresso testing. -->
2526
<base-config cleartextTrafficPermitted="true">
@@ -32,15 +33,21 @@ For example, the Espresso example app has this file in the location `example/and
3233
It is best to put this in a debug or androidTest
3334
AndroidManifest.xml so that you don't ship it to end users. (See the example app of this package.)
3435

35-
Add the following dependencies in android/app/build.gradle:
36+
Add the following dependencies in android/app/build.gradle.kts:
3637

37-
```groovy
38+
<?code-excerpt "android/app/build.gradle.kts (test_dependencies)"?>
39+
```kotlin
3840
dependencies {
3941
testImplementation("junit:junit:4.13.2")
40-
testImplementation("com.google.truth:truth:1.1.3")
42+
// ···
43+
api("androidx.test:core:1.6.1")
44+
// ···
4145
androidTestImplementation("androidx.test:runner:1.6.1")
46+
// ···
47+
androidTestImplementation("com.google.truth:truth:1.1.3")
48+
// ···
4249
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
43-
api("androidx.test:core:1.2.0")
50+
// ···
4451
}
4552
```
4653

@@ -86,25 +93,22 @@ public class MainActivityTest {
8693
}
8794
```
8895

89-
You'll need to create a test app that enables the Flutter driver extension.
90-
You can put this in your test_driver/ folder, e.g. test_driver/example.dart.
91-
Replace `<app_package_name>` with the package name of your app. If you're
92-
developing a plugin, this will be the package name of the example app.
96+
You'll need to create a driver script that hands off to the
97+
[`integration_test`](https://pub.dev/packages/integration_test) package so
98+
`flutter drive`/Espresso can run your Dart integration tests. Put this in your
99+
`test_driver/` folder, e.g. `test_driver/integration_test.dart`:
93100
101+
<?code-excerpt "test_driver/integration_test.dart (Driver)"?>
94102
```dart
95-
import 'package:flutter_driver/driver_extension.dart';
96-
import 'package:<app_package_name>/main.dart' as app;
103+
import 'package:integration_test/integration_test_driver.dart';
97104
98-
void main() {
99-
enableFlutterDriverExtension();
100-
app.main();
101-
}
105+
Future<void> main() => integrationDriver();
102106
```
103107
104108
The following command line command runs the test locally:
105109
106110
```sh
107-
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/example.dart
111+
./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/integration_test.dart
108112
```
109113
110114
Espresso tests can also be run on [Firebase Test Lab](https://firebase.google.com/docs/test-lab):

‎packages/espresso/ci_config.yaml‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎packages/espresso/example/android/app/build.gradle.kts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,36 @@ flutter {
4040
source = "../.."
4141
}
4242

43+
// #docregion test_dependencies
4344
dependencies {
4445
testImplementation("junit:junit:4.13.2")
46+
// #enddocregion test_dependencies
4547

4648
// Multidex
4749
implementation("androidx.multidex:multidex:2.0.1")
4850

4951
// Core library
52+
// #docregion test_dependencies
5053
api("androidx.test:core:1.6.1")
54+
// #enddocregion test_dependencies
5155

5256
// AndroidJUnitRunner and JUnit Rules
57+
// #docregion test_dependencies
5358
androidTestImplementation("androidx.test:runner:1.6.1")
59+
// #enddocregion test_dependencies
5460
androidTestImplementation("androidx.test:rules:1.6.1")
5561

5662
// Assertions
5763
androidTestImplementation("androidx.test.ext:junit:1.2.1")
5864
androidTestImplementation("androidx.test.ext:truth:1.6.0")
65+
// #docregion test_dependencies
5966
androidTestImplementation("com.google.truth:truth:1.1.3")
67+
// #enddocregion test_dependencies
6068

6169
// Espresso dependencies
70+
// #docregion test_dependencies
6271
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
72+
// #enddocregion test_dependencies
6373
androidTestImplementation("androidx.test.espresso:espresso-contrib:3.6.1")
6474
androidTestImplementation("androidx.test.espresso:espresso-intents:3.6.1")
6575
androidTestImplementation("androidx.test.espresso:espresso-accessibility:3.6.1")
@@ -71,4 +81,6 @@ dependencies {
7181
// dependency to appear on your APK's compile classpath or the test APK
7282
// classpath.
7383
androidTestImplementation("androidx.test.espresso:espresso-idling-resource:3.6.1")
84+
// #docregion test_dependencies
7485
}
86+
// #enddocregion test_dependencies
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2+
<!--#docregion network_security_config-->
23
<network-security-config>
34
<!-- Cleartext is needed for Espresso testing. -->
45
<base-config cleartextTrafficPermitted="true">
56
</base-config>
67
</network-security-config>
8+
<!--#enddocregion network_security_config-->

‎packages/espresso/example/test_driver/integration_test.dart‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// #docregion Driver
56
import 'package:integration_test/integration_test_driver.dart';
67

78
Future<void> main() => integrationDriver();
9+
// #enddocregion Driver

‎packages/espresso/pubspec.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso.
33
Allows driving Flutter widgets from a native Espresso test.
44
repository: https://github.com/flutter/packages/tree/main/packages/espresso
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
6-
version: 0.4.0+25
6+
version: 0.4.0+26
77

88
environment:
99
sdk: ^3.10.0

0 commit comments

Comments
 (0)