Skip to content

Commit e4eb735

Browse files
authored
[Espresso] Create integration test and remove exemption (flutter#3367)
[Espresso] Create integration test and remove exemption
1 parent 558b6e3 commit e4eb735

File tree

13 files changed

+82
-98
lines changed

13 files changed

+82
-98
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

2727
android {
2828
compileSdkVersion flutter.compileSdkVersion
29+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
30+
namespace "com.example.espresso_example"
2931

3032
lintOptions {
3133
disable 'InvalidPackage'
3234
}
3335

3436
defaultConfig {
35-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36-
applicationId "com.example.espresso_example"
3737
minSdkVersion 16
3838
targetSdkVersion 29
3939
versionCode flutterVersionCode.toInteger()
4040
versionName flutterVersionName
4141
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
42+
multiDexEnabled true
4243
}
4344

4445
buildTypes {
@@ -56,15 +57,15 @@ flutter {
5657

5758
dependencies {
5859
testImplementation 'junit:junit:4.13.2'
59-
testImplementation "com.google.truth:truth:1.1.3"
60-
androidTestImplementation 'androidx.test:runner:1.1.1'
61-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
60+
61+
// Multidex
62+
implementation "androidx.multidex:multidex:2.0.1"
6263

6364
// Core library
6465
api 'androidx.test:core:1.2.0'
6566

6667
// AndroidJUnitRunner and JUnit Rules
67-
androidTestImplementation 'androidx.test:runner:1.1.0'
68+
androidTestImplementation 'androidx.test:runner:1.2.0'
6869
androidTestImplementation 'androidx.test:rules:1.1.0'
6970

7071
// Assertions

packages/espresso/example/android/app/src/androidTest/java/com/example/MainActivityTest.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package com.example.espresso_example;
6+
7+
import androidx.test.rule.ActivityTestRule;
8+
import dev.flutter.plugins.integration_test.FlutterTestRunner;
9+
import io.flutter.plugins.DartIntegrationTest;
10+
import org.junit.Rule;
11+
import org.junit.runner.RunWith;
12+
13+
@DartIntegrationTest
14+
@RunWith(FlutterTestRunner.class)
15+
public class MainActivityTest {
16+
@Rule
17+
public ActivityTestRule<MainActivity> rule =
18+
new ActivityTestRule<>(MainActivity.class, true, false);
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
package io.flutter.plugins;
6+
7+
import java.lang.annotation.ElementType;
8+
import java.lang.annotation.Retention;
9+
import java.lang.annotation.RetentionPolicy;
10+
import java.lang.annotation.Target;
11+
12+
/*
13+
* Annotation to aid flutter_plugin_tools in determining if a test is a native
14+
* java unit test OR a java class with a dart integration.
15+
*
16+
* See: https://github.com/flutter/flutter/wiki/Plugin-Tests#enabling-android-ui-tests
17+
* for more infomation.
18+
*/
19+
@Retention(RetentionPolicy.RUNTIME)
20+
@Target(ElementType.TYPE)
21+
public @interface DartIntegrationTest {}

packages/espresso/example/android/app/src/main/java/com/example/espresso_example/MainActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
public class MainActivity extends FlutterActivity {
1212
@Override
13-
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {}
13+
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
14+
super.configureFlutterEngine(flutterEngine);
15+
}
1416
}

packages/espresso/example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:7.0.1'
8+
classpath 'com.android.tools.build:gradle:7.3.0'
99
}
1010
}
1111

packages/espresso/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:integration_test/integration_test.dart';
7+
8+
void main() {
9+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
10+
11+
testWidgets('placeholder test', (WidgetTester tester) async {});
12+
}

packages/espresso/example/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ dev_dependencies:
2222
sdk: flutter
2323
flutter_test:
2424
sdk: flutter
25+
integration_test:
26+
sdk: flutter
2527

2628
flutter:
2729
uses-material-design: true

packages/espresso/example/test_driver/example.dart

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

0 commit comments

Comments
 (0)