我似乎无法让测试文件找到Junit4。我已经尝试了很长时间,但仍然感到沮丧。它说无法在org下找到符号junit。我已经搜索了所有的谷歌(几天),甚至安卓文档也说这就是做法。我错在哪里了?
这是我的测试类:
import org.junit.Test;
import android.app.Application;
public class ApplicationTest {
// @Test
public ApplicationTest() {
}
}
这里是我的build.gradle文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
//buildToolsVersion "21.1.2"
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "stuff.morestuffs"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/gson-2.3.1.jar')
testCompile 'junit:junit:4.12'
}
这是我的项目 build.gradle 文件。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
我使用的是Android Studio 1.4。
app\src\androidTest\java\stuff.morestuffs
。让我尝试将它们移动。 - Steve's a Dapp\src\test\java\stuff.morestuffs
。testCompile
用于 JVM 依赖项,androidTestCompile
用于 DVM(dalvik/on device)单元测试。 - iagreen