1
我一直在嘗試使用Android Studio和Gradle的單元測試,但現在我專注於使用./gradlew測試進行所有測試。問題是,我發現了以下錯誤從庫項目:使用終端的gradle進行單元測試CI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:20: error: cannot find symbol
private MockContext context;
^
symbol: class MockContext
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITAssociationAPI.java:19: error: cannot find symbol
RestClient rcAssociationsByEventID = new RestClient("");
^
symbol: class RestClient
location: class ITAssociationAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITAssociationAPI.java:19: error: cannot find symbol
RestClient rcAssociationsByEventID = new RestClient("");
^
symbol: class RestClient
location: class ITAssociationAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:30: error: cannot find symbol
RestClient rcLeadsByEventID = new RestClient(base_url + "/rest/event/" + EVENT_ID);
^
symbol: class RestClient
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:30: error: cannot find symbol
RestClient rcLeadsByEventID = new RestClient(base_url + "/rest/event/" + EVENT_ID);
^
symbol: class RestClient
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:38: error: cannot find symbol
RestClient rcTagsCode = new RestClient(base_url + "/rest/event/tags");
^
symbol: class RestClient
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:38: error: cannot find symbol
RestClient rcTagsCode = new RestClient(base_url + "/rest/event/tags");
^
symbol: class RestClient
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:46: error: cannot find symbol
RestClient rcLeadEventsByTag = new RestClient(base_url + "/rest/eventtag/" + TAG + "/events");
^
symbol: class RestClient
location: class ITEventsAPI
/Users/Radsen/Projects/Mobile/AllianceTech/androidstudio/ATDroidUtils/app/src/test/java/com/alliancetech/ileadsalpha/ITEventsAPI.java:46: error: cannot find symbol
RestClient rcLeadEventsByTag = new RestClient(base_url + "/rest/eventtag/" + TAG + "/events");
這裏是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.alliancetech.ileadsalpha"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
sourceSets {
instrumentTest.setRoot('src/test')
}
}
sourceSets {
unitTest {
java.srcDir file('src/test')
resources.srcDir file('src/test/resources')
}
}
configurations{
unitTestCompile.extendsFrom runtime
unitTestRuntime.extendsFrom unitTestCompile
}
dependencies {
compile 'junit:junit:4.12'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'org.roboguice:roboguice:2.0'
compile project(':atdroidutilslib')
//unitTestCompile 'junit:junit:4.12'
//unitTestCompile 'com.googlecode.json-simple:json-simple:1.1'
unitTestCompile "org.apache.httpcomponents:httpmime:4.2.3"
unitTestCompile project(':atdroidutilslib')
}
task iLeadsIntegrationTests(type:Test, dependsOn: assemble) {
testClassesDir = project.sourceSets.unitTest.output.classesDir
classpath = project.sourceSets.unitTest.runtimeClasspath
}
check.dependsOn iLeadsIntegrationTests
你做了什麼來解決你的問題? – 2015-03-08 04:50:57
爲了解決我在這裏遇到的問題,我遵循了我從另一個答案發布的鏈接。但我有其他人使用它從詹金斯。你能告訴我你是否有能力使用控制檯從工作站上運行測試嗎? – Dyan 2015-03-09 18:40:42