So basically I have a program that utilizes Robotium to run tests on an android device, and all the tests work great. Certain tests also have timestamps, and I want to save those timestamps to a file so I can use them elsewhere, so I wrote a simple method.
public static void saveTimestamps(Timestamp ts) throws IOException {
FileWriter fw = new FileWriter(
"C:\\Users\\brendonn\\workspace\\TestProject\\timestamps.txt");
fw.write(ts.toString());
fw.close();
}
But for every test that uses this method I get
java.io.FileNotFoundException: /timestamps.txt (Read-only file system)
And I’m not sure where to go from here. I’m not trying to write to the phone, I’m just writing a text file to my computer. I can do the exact same thing in other classes on this computer and it works.
As near as I can see from a quick look at the Robotium home page, this tool runs ON the target system! If that’s correct, your method is trying to write to something on the Android device, where the path doesn’t exist.
Note that the front page of the Robotium project talks about a future feature of running the tests from the PC.
You could try saving the timings to a file on the target device (the app would need permission to write somewhere), or you could perhaps send the data out as log messages and capture the log output on your PC.