1

안녕하세요. 내 데모 Android 애플리케이션의 단위 테스트 케이스를 작성하고 있습니다.이 경우 robolectric 유닛 프레임 워크를 사용하고 있습니다. 내가 그것을 실행할 때 gradlew test 그러면 구성 'app : testCompile`에 대한 모든 종속성을 해결할 수 없습니다. 첨부 된 스크린 샷을 참조하십시오. 다음은 오류 : Robolectric의 'app : testCompile'구성에 대한 모든 종속성을 확인할 수 없습니다.

내 루트 build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules. 

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.12.2' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

내 프로젝트 build.grade 파일

apply plugin: 'android' 

android { 
    compileSdkVersion 20 
    buildToolsVersion "20.0.0" 

    defaultConfig { 
     applicationId "com.example.xyz.robolectricapplication" 
     minSdkVersion 15 
     targetSdkVersion 20 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      runProguard false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    sourceSets { 
     // this sets the root test folder to src/test overriding the default src/instrumentTest 
     instrumentTest.setRoot('src/test') 
    } 
} 

apply plugin: 'android-test' 


dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.10' 
    testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 
    testCompile 'com.squareup:fest-android:1.0.+' 
    instrumentTestCompile 'junit:junit:4.10' 
    instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 
    instrumentTestCompile 'com.squareup:fest-android:1.0.+' 
} 

buildscript { 
    repositories { 
     mavenCentral() 
     maven { 
      url 'https://oss.sonatype.org/content/repositories/snapshots/' 
     } 
    } 
    dependencies { 
     classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT' 
    } 
} 

repositories { 
    mavenCentral() 
    maven { 
     url 'https://oss.sonatype.org/content/repositories/snapshots/' 
    } 
} 

아래의 오류 로그처럼 보이는

build.gradle입니다

enter image description here

프로젝트 구조는 사전에 enter image description here

아래에 감사 같습니다.

답변

0

스냅 샷을 잡으려면 2.4-SNAPSHOT을 잡아야합니다.

참조 : 도움이 될 수도, org.robolectric:robolectric:2.3

샘플 Gradle을 프로젝트가 여기에 있습니다 : : https://github.com/robolectric/robolectric/blob/master/pom.xml

그래서 안정적인 2.3 릴리스를 잡아 testCompile 'org.robolectric:robolectric:2.4-SNAPSHOT'

또는 아마 더 나은 함께 testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' 교체 https://github.com/robolectric/deckard-gradle

관련 문제