I am trying to add some unit tests to my application. I am developing an application in Android Studio
This is what I did.
@SmallTest
public void basicTest() {
assertEquals("abc", "abc");
}
- The following section
defaultConfigis added inbuild.gradle
testApplicationId "newly.added.package.name"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
- The following command is executed in the Android Studio terminal
gradlew.bat connectedAndroidTest
But when I checked the generated html report, it shows that 0 tests were performed.
I tried to follow, but none of them influenced the output of the command gradlew.bat connectedAndroidTest.
- Incorrect package name added
testApplicationIdin build.gradle. - Disconnected device
Why is my test case not running? What did I miss?
Below is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "my.package.name"
minSdkVersion 12
targetSdkVersion 18
testApplicationId "my.package.name.tests"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile project(':my_sub_module1')
compile project(':my_sub_module2')
compile 'com.android.support:support-v4:21.0.2'
compile files('libs/my_dependent_lib-1-7-4.jar')
compile 'com.google.code.gson:gson:2.3'
}
repositories {
mavenCentral()
}