Menu

#1 Persistence #3 - Filename in MyUtilitiesTest

open
nobody
None
5
2011-06-02
2011-06-02
Anonymous
No

In the Persistence tutorial, chapter 3, there are some statemente addes to the test method named saveStringToFile of the MyUtilitiesTest class.
At first the filename used is "testsavetostring,txt"
>> File testFile = new File("testsavetostring.txt");
>> testFile.delete();
>> assertFalse("File should not exist",testFile.exists());
and with these lines you can be sure that the file "testsavetosting.txt" doesn't exist.
But afterwards in the assert..-statements the filename referenced is spelled "testsavestring.txt" (without the 'to').
Because the filenames don't match, you can't be sure, that you accidentally run the following tests with an current version of the file (because the "testsavestring.txt" is obviously not deleted).
The solution is rather simple: remove the 'to' in the filename as follows 'File testFile = new File("testsavestring.txt").
By the way: Great effort, the tutorials are very helpful.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.