I'm trying to write unit tests for an Android Studio project, but the console just spits out an error:
Testing started at 11:02 ...
No apk changes detected. Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND: am force-stop {package name}
Running tests
Test running startedTest running failed: Instrumentation run failed due to 'java.lang.RuntimeException'
Empty test suite.
I've only written the one test that should just return true. The file is in the src/test/{package} directory, which is an exact duplicate of the code directory but test instead of main. Android Studio seems to think that part is fine, it's highlighted the file green etc and is marked as a test.
import junit.framework.TestCase;
import org.junit.Test;
public class QuestionTest extends TestCase {
@Test
public void checkExpiryDateSetting(){
assertTrue(true);
}
}
Gradle build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.example.s1300465.votingapplication"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.+'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
}
Aucun commentaire:
Enregistrer un commentaire