1

Robolectric을 성공적으로 설치했지만 테스트가 전혀 실행되지 않습니다. 오류는 없지만 결과는 없습니다. 내가 놓친 게 무엇입니까?Robolectric 테스트가 실행되지 않음 (Android)

./gradlew 테스트를 실행 한 후가 더 테스트 보고서는 없지만, 테스트 클래스가 제대로

를 생성하는 내 build.gradle :

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url 'https://maven.fabric.io/repo' } 
    } 
    dependencies { 
     ... 
     classpath 'io.fabric.tools:gradle:1.+' 
     classpath 'org.robolectric:robolectric-gradle-plugin:0.11.+' 
    } 
}  
allprojects { 
    repositories { 
     mavenCentral() 
    } 
} 
apply plugin: 'android-sdk-manager' 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'idea' 
apply plugin: 'hugo' 
apply plugin: 'android' 
apply plugin: 'robolectric' 

idea { 
    module { 
     downloadJavadoc = true 
     downloadSources = true 
     testOutputDir = file('build/test-classes/debug') 
    } 
}  
repositories { 
    mavenCentral() 
    maven { url 'https://repo.commonsware.com.s3.amazonaws.com' } 
    flatDir name: 'localRepository', dirs: 'libs-aar' 
    maven { url 'https://maven.fabric.io/repo' } 
}  
dependencies { 
    repositories { 
     mavenCentral() 
    } 
    ...  
    // Espresso 
    androidTestCompile files('lib/espresso-1.1.jar', 'lib/testrunner-1.1.jar', 'lib/testrunner-runtime-1.1.jar') 
    androidTestCompile 'com.google.guava:guava:14.0.1' 
    androidTestCompile 'com.squareup.dagger:dagger:1.1.0' 
    androidTestCompile 'org.hamcrest:hamcrest-integration:1.1' 
    androidTestCompile 'org.hamcrest:hamcrest-core:1.1' 
    androidTestCompile 'org.hamcrest:hamcrest-library:1.1'  
    androidTestCompile('junit:junit:4.11') { 
     exclude module: 'hamcrest-core' 
    } 
    androidTestCompile('org.robolectric:robolectric:2.3') { 
     exclude module: 'classworlds' 
     exclude module: 'commons-logging' 
     exclude module: 'httpclient' 
     exclude module: 'maven-artifact' 
     exclude module: 'maven-artifact-manager' 
     exclude module: 'maven-error-diagnostics' 
     exclude module: 'maven-model' 
     exclude module: 'maven-project' 
     exclude module: 'maven-settings' 
     exclude module: 'plexus-container-default' 
     exclude module: 'plexus-interpolation' 
     exclude module: 'plexus-utils' 
     exclude module: 'wagon-file' 
     exclude module: 'wagon-http-lightweight' 
     exclude module: 'wagon-provider-api' 
    } 
    androidTestCompile 'com.squareup:fest-android:1.0.+' 
}  
android { 
    compileSdkVersion 19 
    buildToolsVersion '19.1.0' 
    useOldManifestMerger true  
    defaultConfig { 
     minSdkVersion 11 
     targetSdkVersion 19 
     buildConfigField "String", "GIT_SHA", "\"${gitSha()}\"" 
     testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner" 
//  buildConfigField "String", "BUILD_TIME", buildTime() 
    } 
    ...  
sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src/com', 'src/se', 'src/viewpagerindicator' , 'src-gen'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     }  
     ... 
     androidTest { 
       setRoot('src/androidTest') 
     } 
    }  
    packagingOptions { 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'LICENSE.txt' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/NOTICE' 
    } 
} 
...  
robolectric { 
    include '**/*Tests.class' 
    exclude '**/espresso/**/*.class' 
} 

그리고 내 시험 :

@RunWith(RobolectricTestRunner.class) 
public class StartTest { 
    @Test 
    public void testSomething() throws Exception { 
     //Activity activity = Robolectric.buildActivity(DeckardActivity.class).create().get(); 
     assertTrue(true); 
    } 
} 

답변

2

문제는 파일 마스크 때문이라고 생각합니다. 테스트 .class를 포함하고 있지만 클래스는 StartTest (누락 된)에 포함되므로 포함되지 않습니다.

+0

정답을위한 Thx 메이트, 저 역시 저의 문제였습니다. :) –