android 个本地测试的数据文件

Data files for android local tests

我有一个 android 应用程序,其模块执行数据处理(HTML 实际上是抓取)。这部分是纯 java 并且它的所有测试都在 src/test 路径中。

我的特殊问题是我有一组(大型)文件要由测试解析,我需要一种可靠的方式来访问这些文件。我知道最佳做法是将文件保持内联,但将 300k 左右的内容转储到字符串中并不理想。

been sources and I'd like to know if there is an alternative to the .

通过将所有测试文件放在 src/test/resources 中并通过以下方式访问它们,它对我有用:

InputStream inputStream = this.getClass()
    .getClassLoader()
    .getResourceAsStream(path);

其中 pathsrc/test/resources 的相对路径。

根据当前安排(AS 2.0.0-beta6,gradle 2.10),资源被复制到build/intermediates/sourceFolderJavaResources