alaurenz / metrobike

0 stars 1 forks source link

Fail the file input output test #161

Closed sw11 closed 11 years ago

sw11 commented 11 years ago

I will try to work on this issue. Please let me know if any of you can get it to work on your local machine.

dutchscout commented 11 years ago

I'm having this problem on my machine. Note that I'm having a problem in the emulator. Are you running this code in pure Java? I think the file system is a bit different in pure Java. I'm trying to fix the tests to work in the Android emulator.

dutchscout commented 11 years ago

Basically, I can't create or write the file in my current system.

dutchscout commented 11 years ago

Learned: Under the JUnit tests for Android, the default directory is / so when we try to create ./testFile, it's trying to create a new file in the emulator file system root, which fails for permissions reasons.

I'm still searching for a directory I can write in :/

dutchscout commented 11 years ago

Ok. I think I've got something working:

The problems here are (1) we can't use standard Android tools for files and (2) JUnit tests don't appear to have file creation privileges (seemingly at all).

We can write to a file like "/data/data/com.HuskySoft.metrobike/lib/testFile.txt", but only if it's been created before we start the test: (start emulator, install MetroBike) adb shell cd /data/data/com.HuskySoft.metrobike/lib/ touch testFile.txt

There may be a way to get a few scratch-pad files (for testing only) into the .apk so we don't have to make them manually, but I can't figure out how else to get file I/O working.

Having spent a bunch of time on this, I'm stopping work on discovery for this issue. If we need files to access during JUnit testing, we can create them beforehand and then use them in JUnit testing.

sw11 commented 11 years ago

Thanks for your work! It looks like it won't get to work on Jenkins. May be I will tried to refactor other code from activity to utility test in order to increase the coverage. Thanks