2

My problem is the following: I have got a Robolectric Test case. The test case is creating a file in the test startup. Let me call this file Properties.txt.

The testcase itself will need this Properties.txt file. So I call:

AssetManager am = context.getAssets();
am.open(fileName);

The second line will lead to a FileNotFoundException. If I debug at this certain place I can see that the File is already created in the File System but Robolectric can not read the file.

So far so good, I think that's somehow logical. I assume Robolectric just loads a Reflection of the file system so it wont see runtime created files/assets.

Is it possible to somehow trigger a reload or enter an absolute path where Robolectric should always assume there is a file?

Highriser
  • 212
  • 2
  • 14

1 Answers1

0

Is this resource being created in assets folder?

Else you need to pass full path name trough a FileInputStream to read.

Marcos Vasconcelos
  • 18,136
  • 30
  • 106
  • 167