0

I've got an android application with a module performing data processing (HTML scraping in fact). This part is pure java and all its tests are in the src/test path.

My particular problem is that I have a set of (large-ish) files to be parsed by the tests and I need a reliable way to access these files. I know that best practice would be to keep the files inline, but dumping 300k-ish content in strings is not ideal.

I've been reading various sources and I'd like to know if there is an alternative to the gradle trick.

Community
  • 1
  • 1
Laur Ivan
  • 4,117
  • 3
  • 38
  • 62

1 Answers1

1

It works for me by placing all the test files in src/test/resources and accessing them via:

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

where path is the relative path to src/test/resources.

With the current arrangement (AS 2.0.0-beta6, gradle 2.10), the resources are copied into build/intermediates/sourceFolderJavaResources.

Laur Ivan
  • 4,117
  • 3
  • 38
  • 62