This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[espresso] Adds EspressoFlutter as a first-party plugin #2369
Merged
collinjackson
merged 43 commits into
flutter:master
from
collinjackson:new_espresso_plugin
Jan 10, 2020
Merged
Changes from 27 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
1743eab
Initial copy of e2e plugin renamed to espresso
collinjackson 0bf791e
Switch to a new project based on template plugin
collinjackson f47c5a4
Update example app to be a button app
collinjackson 45bf214
switch to Java
collinjackson 195bb22
Add example Espresso test
collinjackson fded8ad
Midpoint check-in while addressing dependency errors
collinjackson 60da0af
Demonstration of Espresso tests passing
collinjackson 4f65053
All tests pass
collinjackson 7c77635
Add shared preferences integration test
collinjackson 86f133c
Fix test to match internal version
collinjackson 02adfc8
Tests pass for shared prefs plugin
collinjackson f343591
Open source Espresso files
collinjackson 521eb6c
License
collinjackson f2e0e56
SDK constraints
collinjackson 6b86f04
Update README, changelog, remove test
collinjackson 0b70161
Revert shared_preferences
collinjackson ce9de53
Update README.md
collinjackson cc2ebe5
Update README to make it clear this package is Android-only
collinjackson 11b38af
Update licenses
collinjackson da89fee
Merge remote-tracking branch 'cj/new_espresso_plugin' into new_espres…
collinjackson 211e358
remove commented dependencies
collinjackson b823741
More README updates
collinjackson 5a1d274
Add a click test
collinjackson 226a0d6
Fix build error
collinjackson 2d0d9a1
More README updates
collinjackson 0a2b5ab
fix file that wasn't meant to be checked in
collinjackson 56360ff
Update README
collinjackson e3d340c
Merge remote-tracking branch 'origin/master' into new_espresso_plugin
collinjackson 5377d27
Fix build failure
collinjackson 8663ebd
Update README.md
collinjackson f69d012
Update README to clarify that iOS example is for the bots.
collinjackson a33410d
Code review feedback on plaintext traffic
collinjackson 3a00269
Update README.md
collinjackson e5c1ae1
reformat
collinjackson 5bf41b2
update pubspec.yaml
collinjackson 9a85ad9
remove unused test
collinjackson d69e407
reformat
collinjackson 6b6ff85
Merge remote-tracking branch 'origin/master' into new_espresso_plugin
collinjackson acef95e
Merge remote-tracking branch 'cj/new_espresso_plugin' into new_espres…
collinjackson a5a9c46
Fix analyzer issues
collinjackson 8b6542b
fix ios build
collinjackson d18b2a0
remove lib/espresso.dart
collinjackson 8129481
reformat
collinjackson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| .DS_Store | ||
| .dart_tool/ | ||
|
|
||
| .packages | ||
| .pub/ | ||
|
|
||
| build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # This file tracks properties of this Flutter project. | ||
| # Used by Flutter tool to assess capabilities and perform upgrades etc. | ||
| # | ||
| # This file should be version controlled and should not be manually edited. | ||
|
|
||
| version: | ||
| revision: 0190e40457d43e17bdfaf046dfa634cbc5bf28b9 | ||
| channel: unknown | ||
|
|
||
| project_type: plugin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 0.0.1 | ||
|
|
||
| * Initial open-source release of Espresso bindings for Flutter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright 2019 The Chromium Authors. All rights reserved. | ||
| // | ||
| // Redistribution and use in source and binary forms, with or without | ||
| // modification, are permitted provided that the following conditions are | ||
| // met: | ||
| // | ||
| // * Redistributions of source code must retain the above copyright | ||
| // notice, this list of conditions and the following disclaimer. | ||
| // * Redistributions in binary form must reproduce the above | ||
| // copyright notice, this list of conditions and the following disclaimer | ||
| // in the documentation and/or other materials provided with the | ||
| // distribution. | ||
| // * Neither the name of Google Inc. nor the names of its | ||
| // contributors may be used to endorse or promote products derived from | ||
| // this software without specific prior written permission. | ||
| // | ||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # espresso | ||
|
|
||
| Provides bindings for Espresso tests of Flutter Android apps. | ||
|
|
||
| ## Installation | ||
|
|
||
| Add ```android:usesCleartextTraffic="true"``` in the ```<application>``` in the AndroidManifest.xml | ||
| of the Android app used for testing. | ||
|
|
||
| Add dependencies to your build.gradle: | ||
|
|
||
| ``` | ||
collinjackson marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dependencies { | ||
| testImplementation 'junit:junit:4.12' | ||
| testImplementation "com.google.truth:truth:1.0" | ||
| androidTestImplementation 'androidx.test:runner:1.1.1' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' | ||
|
|
||
| // Core library | ||
| api 'androidx.test:core:1.2.0' | ||
|
|
||
| // AndroidJUnitRunner and JUnit Rules | ||
| androidTestImplementation 'androidx.test:runner:1.1.0' | ||
| androidTestImplementation 'androidx.test:rules:1.1.0' | ||
|
|
||
| // Assertions | ||
| androidTestImplementation 'androidx.test.ext:junit:1.0.0' | ||
| androidTestImplementation 'androidx.test.ext:truth:1.0.0' | ||
| androidTestImplementation 'com.google.truth:truth:0.42' | ||
|
|
||
| // Espresso dependencies | ||
| androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.1.0' | ||
| androidTestImplementation 'androidx.test.espresso:espresso-web:3.1.0' | ||
| androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.1.0' | ||
|
|
||
| // The following Espresso dependency can be either "implementation" | ||
| // or "androidTestImplementation", depending on whether you want the | ||
| // dependency to appear on your APK's compile classpath or the test APK | ||
| // classpath. | ||
| androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.1.0' | ||
| } | ||
| ``` | ||
|
|
||
| Create an `android/app/src/androidTest` folder and put a test file in a package-appropriate subfolder, e.g. `android/app/src/androidTest/java/com/example/MainActivityTest.java`: | ||
|
|
||
| ``` | ||
| package com.example.espresso_example; | ||
|
|
||
| import static androidx.test.espresso.flutter.EspressoFlutter.onFlutterWidget; | ||
| import static androidx.test.espresso.flutter.action.FlutterActions.click; | ||
| import static androidx.test.espresso.flutter.action.FlutterActions.syntheticClick; | ||
| import static androidx.test.espresso.flutter.assertion.FlutterAssertions.matches; | ||
| import static androidx.test.espresso.flutter.matcher.FlutterMatchers.isDescendantOf; | ||
| import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withText; | ||
| import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withTooltip; | ||
| import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withType; | ||
| import static androidx.test.espresso.flutter.matcher.FlutterMatchers.withValueKey; | ||
| import static com.google.common.truth.Truth.assertThat; | ||
| import static org.junit.Assert.fail; | ||
|
|
||
| import androidx.test.core.app.ActivityScenario; | ||
| import androidx.test.espresso.flutter.EspressoFlutter.WidgetInteraction; | ||
| import androidx.test.espresso.flutter.assertion.FlutterAssertions; | ||
| import androidx.test.espresso.flutter.matcher.FlutterMatchers; | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
| import org.junit.Before; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
|
|
||
| /** Unit tests for {@link EspressoFlutter}. */ | ||
| @RunWith(AndroidJUnit4.class) | ||
| public class MainActivityTest { | ||
|
|
||
| @Before | ||
| public void setUp() throws Exception { | ||
| ActivityScenario.launch(MainActivity.class); | ||
| } | ||
|
|
||
| @Test | ||
| public void performClick() { | ||
| onFlutterWidget(withTooltip("Increment")).perform(click()); | ||
| onFlutterWidget(withValueKey("CountText")).check(matches(withText("Button tapped 1 time."))); | ||
| } | ||
| ``` | ||
|
|
||
| You'll need to create a test app that enables the Flutter driver extension. | ||
| You can put this in your test_driver/ folder, e.g. test_driver/example.dart. | ||
|
|
||
| ``` | ||
| import 'package:flutter_driver/driver_extension.dart'; | ||
| import '../lib/main.dart' as app; | ||
|
|
||
| void main() { | ||
| enableFlutterDriverExtension(); | ||
| app.main(); | ||
| } | ||
| ``` | ||
|
|
||
| The following command line command runs the test locally: | ||
|
|
||
| ``` | ||
| ./gradlew app:connectedAndroidTest -Ptarget=`pwd`/../test_driver/example.dart | ||
| ``` | ||
|
|
||
| Espresso tests can also be run on [Firebase Test Lab](https://firebase.google.com/docs/test-lab): | ||
|
|
||
| ``` | ||
| ./gradlew app:assembleAndroidTest | ||
| ./gradlew app:assembleDebug -Ptarget=<path_to_test>.dart | ||
| gcloud auth activate-service-account --key-file=<PATH_TO_KEY_FILE> | ||
| gcloud --quiet config set project <PROJECT_NAME> | ||
| gcloud firebase test android run --type instrumentation \ | ||
| --app build/app/outputs/apk/debug/app-debug.apk \ | ||
| --test build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk\ | ||
| --timeout 2m \ | ||
| --results-bucket=<RESULTS_BUCKET> \ | ||
| --results-dir=<RESULTS_DIRECTORY> | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| *.iml | ||
| .gradle | ||
| /local.properties | ||
| /.idea/workspace.xml | ||
| /.idea/libraries | ||
| .DS_Store | ||
| /build | ||
| /captures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| group 'com.example.espresso' | ||
| version '1.0' | ||
|
|
||
| buildscript { | ||
| repositories { | ||
| google() | ||
| jcenter() | ||
| } | ||
|
|
||
| dependencies { | ||
| classpath 'com.android.tools.build:gradle:3.5.0' | ||
| } | ||
| } | ||
|
|
||
| rootProject.allprojects { | ||
| repositories { | ||
| google() | ||
| jcenter() | ||
| } | ||
| } | ||
|
|
||
| apply plugin: 'com.android.library' | ||
|
|
||
| android { | ||
| compileSdkVersion 28 | ||
|
|
||
| defaultConfig { | ||
| minSdkVersion 16 | ||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| } | ||
| lintOptions { | ||
| disable 'InvalidPackage' | ||
| } | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'com.google.guava:guava:28.1-android' | ||
| implementation 'com.squareup.okhttp3:okhttp:3.12.1' | ||
| implementation 'com.google.code.gson:gson:2.8.6' | ||
| androidTestImplementation 'org.hamcrest:hamcrest:2.2' | ||
|
|
||
| testImplementation 'junit:junit:4.12' | ||
| testImplementation "com.google.truth:truth:1.0" | ||
| api 'androidx.test:runner:1.1.1' | ||
| api 'androidx.test.espresso:espresso-core:3.1.1' | ||
|
|
||
| // Core library | ||
| api 'androidx.test:core:1.0.0' | ||
|
|
||
| // AndroidJUnitRunner and JUnit Rules | ||
| api 'androidx.test:runner:1.1.0' | ||
| api 'androidx.test:rules:1.1.0' | ||
|
|
||
| // Assertions | ||
| api 'androidx.test.ext:junit:1.0.0' | ||
| api 'androidx.test.ext:truth:1.0.0' | ||
| api 'com.google.truth:truth:0.42' | ||
|
|
||
| // Espresso dependencies | ||
| api 'androidx.test.espresso:espresso-core:3.1.0' | ||
| api 'androidx.test.espresso:espresso-contrib:3.1.0' | ||
| api 'androidx.test.espresso:espresso-intents:3.1.0' | ||
| api 'androidx.test.espresso:espresso-accessibility:3.1.0' | ||
| api 'androidx.test.espresso:espresso-web:3.1.0' | ||
| api 'androidx.test.espresso.idling:idling-concurrent:3.1.0' | ||
|
|
||
| // The following Espresso dependency can be either "implementation" | ||
| // or "androidTestImplementation", depending on whether you want the | ||
| // dependency to appear on your APK's compile classpath or the test APK | ||
| // classpath. | ||
| api 'androidx.test.espresso:espresso-idling-resource:3.1.0' | ||
| } | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| org.gradle.jvmargs=-Xmx1536M | ||
| android.enableR8=true | ||
| android.useAndroidX=true | ||
| android.enableJetifier=true |
6 changes: 6 additions & 0 deletions
6
packages/espresso/android/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #Tue Nov 26 13:04:21 PST 2019 | ||
| distributionBase=GRADLE_USER_HOME | ||
| distributionPath=wrapper/dists | ||
| zipStoreBase=GRADLE_USER_HOME | ||
| zipStorePath=wrapper/dists | ||
| distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| rootProject.name = 'espresso' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| package="com.example.espresso"> | ||
| </manifest> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.