Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save venkata-kari/e538bb03442574ca32f1dbfb4d75649c to your computer and use it in GitHub Desktop.
Save venkata-kari/e538bb03442574ca32f1dbfb4d75649c to your computer and use it in GitHub Desktop.
module-flavor1-androidTest-only
<?xml version="1.0" encoding="utf-8"?><!--
Copyright 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.testing.blueprint.test">
<!-- Specify runner and target application package -->
<instrumentation
android:name="android.support.test.runner.AndroidJUnitRunner"
android:targetPackage="com.example.android.testing.blueprint.flavor1" />
<application>
<uses-library android:name="android.test.runner" />
</application>
</manifest>
//module-flavor1-androidTest-only build.gradle
apply plugin: 'com.android.test' // A plugin used for test-only-modules
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
// The package name of the test app
testApplicationId 'com.example.android.testing.blueprint.test'
// The Instrumentation test runner used to run tests.
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
// Set the target app project. The module specified here should contain the production code
// test should run against.
targetProjectPath ':app'
targetVariant 'flavor1Debug'
}
dependencies {
// Android Testing Support Library's runner and rules and hamcrest matchers
compile('com.android.support.test.espresso:espresso-core:2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'junit', module: 'junit'
}
compile 'com.android.support.test:runner:' + rootProject.ext.runnerVersion
compile 'com.android.support.test:rules:' + rootProject.ext.rulesVersion
compile 'org.hamcrest:hamcrest-core:' + rootProject.ext.hamcrestVersion
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
ext {
minSdkVersion = 10
targetSdkVersion = 23
compileSdkVersion = 23
buildToolsVersion = "24"
supportLibVersion = "23.1.1"
junitVersion = "4.12"
mockitoVersion = "1.10.19"
hamcrestVersion = "1.3"
runnerVersion = "0.5"
rulesVersion = "0.5"
espressoVersion = "2.2.2"
uiautomatorVersion = "2.1.2"
}
@venkata-kari
Copy link
Author

To run the tests from module-flavor1-androidTest-only, created a new configuration as shown below.

screen shot 2016-06-23 at 18 00 55

@venkata-kari
Copy link
Author

When I try to run the individual test from module-flavor1-androidTest-only; JUnit test configuration applied instead of Android Test.

screen shot 2016-06-23 at 18 07 07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment