Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在资产文件上找不到Robolectric文件_Android_Unit Testing_Gradle_Robolectric_Robolectric Gradle Plugin - Fatal编程技术网

Android 在资产文件上找不到Robolectric文件

Android 在资产文件上找不到Robolectric文件,android,unit-testing,gradle,robolectric,robolectric-gradle-plugin,Android,Unit Testing,Gradle,Robolectric,Robolectric Gradle Plugin,您好,我正在使用robolectric 3.0版对我的应用程序进行单元测试,并且在src/test/assets下有一个asssets文件夹,其中包含一些文件,但不断获取fileNotFound 以下是我的测试代码: ``` ``` 以下是我的gradle文件中的源集和依赖项: ``` ``` 生产是一个构建变量我认为这是因为Config.NONE。您是否可以不使用而指定常量=BuildConfig.class? @RunWith(RobolectricGradleTestRunner.clas

您好,我正在使用robolectric 3.0版对我的应用程序进行单元测试,并且在src/test/assets下有一个asssets文件夹,其中包含一些文件,但不断获取fileNotFound

以下是我的测试代码:

```

```

以下是我的gradle文件中的源集和依赖项: ```

```


生产是一个构建变量

我认为这是因为
Config.NONE
。您是否可以不使用而指定
常量=BuildConfig.class
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, manifest = Config.NONE)
public class ShowsDatesTest {

@Test
public void testResponse(){
BufferedReader = getBufferedResponseFromFile("response.json");
}

private BufferedReader getBufferedResponseFromFile(String json) throws IOException {

         mContext = RuntimeEnvironment.application;
        InputStream jsonResponse = mContext.getAssets().open(json);

        BufferedReader br = new BufferedReader(new InputStreamReader(jsonResponse, "UTF-8"));

        return br;

    }

}
 production {
            res.srcDir 'build-config/production/res'
            test.java.srcDirs += 'src/main/java'
            test.java.srcDirs += "build/generated/source/r/production"
            test.java.srcDirs += "build/generated/source/buildConfig/production"
            test.assets.srcDir file('src/test/assets')
        }

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.1.+'
    compile 'com.google.code.gson:gson:2.3'
    testCompile('org.robolectric:robolectric:3.0') {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    compile 'com.fasterxml.jackson:jackson-parent:2.5'
    compile 'com.squareup:otto:1.3.6'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.sothree.slidinguppanel:library:3.0.0'
    compile 'com.crashlytics.android:crashlytics:1.+'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0'
    compile 'joda-time:joda-time:2.8.2'
    testCompile('junit:junit:4.12') {
        exclude module: 'hamcrest'
        exclude module: 'hamcrest-core'
    }
    testCompile 'org.hamcrest:hamcrest-all:1.3'
    compile 'com.sothree.slidinguppanel:library:3.0.0'
    compile 'com.squareup:otto:1.3.6'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    testCompile 'org.apache.maven:maven-ant-tasks:2.1.3'

    compile 'com.google.android.gms:play-services:7.0.0'

    compile 'com.android.support:multidex:1.0.0'

    compile 'com.android.support:recyclerview-v7:21.0.+'
    compile 'com.squareup.picasso:picasso:2.5.2'