android for junit,在Gradle for Android应用程序中运行JUnit测试
我想在我的Android应用程序项目中运行简单,简单的JUnit测试,同时使用Gradle编写Activity测试.花了很长时间配置Gradle并使其工作,但是,无论如何,现在我仍然试图让JUnit测试只是编译.我检查了这个link,但是当我运行gradle时,我收到以下错误:DummyTest.java:3: error: package junit.framework does not exi
我想在我的
Android应用程序项目中运行简单,简单的JUnit测试,同时使用Gradle编写Activity测试.花了很长时间配置Gradle并使其工作,但是,无论如何,现在我仍然试图让JUnit测试只是编译.
我检查了这个link,但是当我运行gradle时,我收到以下错误:
DummyTest.java:3: error: package junit.
framework does not exist
import junit.framework.Assert;
^
\DummyTest.java:8: error: cannot find symbol
Assert.assertEquals(5,3);
^
symbol: variable Assert
location: class DummyTest
所以,找不到junit ……
以下是我的完整gradle.build文件:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
compile files('libs/joda-time-2.3.jar')
compile files('libs/android-support-v4.jar')
unitTestCompile files("$project.buildDir/classes/release")
unitTestCompile 'junit:junit:4.8.2'
}
android {
compileSdkVersion 17
buildToolsVersion '17.0.0'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
}
unitTest {
java.srcDir file('test')
resources.srcDir file('test/res')
}
}
defaultConfig {
minSdkVersion 14
versionName '1.0'
versionCode 1
targetSdkVersion 17
}
}
// add the unitTest task
task unitTest(type:Test, dependsOn: assemble) {
description = "run unit tests"
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
build.dependsOn unitTest
更多推荐
所有评论(0)