Thanks for offering these great tutorials. I'm new to Java and Eclipse. My questions arises from the message chosen for the assertFalse statement in MyUtilitiesTest.java, in the code segment:
File testFile = new File("testsavetostring.txt");
testFile.delete();
assertFalse ("File should not exists", testFile.exists());
The 2nd statement deleted the file "testFiile", and the 3rd statement appears as if it's going to put out the message "File should not exists" because the assertFalse statement succeeded, ie. the condition testFile.exists() returned FALSE. I followed the logic here, but is confused by the message. I can't tell if the message is meant to affirm the condition, or raise a concern.
Is my understanding correct?
If I understand the code logic correctly, I'd be less confused if an assertTrue() or assertFalse() return no message at all if everything is as expected.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. The message in the assertFalse() statement only shows if the assert fails. So the message is designed to tell you what went wrong. In this case, if the file exists (because the assertFalse() failed), the message tells you that "File should not exist", so that is what is wrong. It is a little confusing. Good luck! Mark
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for offering these great tutorials. I'm new to Java and Eclipse. My questions arises from the message chosen for the assertFalse statement in MyUtilitiesTest.java, in the code segment:
File testFile = new File("testsavetostring.txt");
testFile.delete();
assertFalse ("File should not exists", testFile.exists());
The 2nd statement deleted the file "testFiile", and the 3rd statement appears as if it's going to put out the message "File should not exists" because the assertFalse statement succeeded, ie. the condition testFile.exists() returned FALSE. I followed the logic here, but is confused by the message. I can't tell if the message is meant to affirm the condition, or raise a concern.
Is my understanding correct?
If I understand the code logic correctly, I'd be less confused if an assertTrue() or assertFalse() return no message at all if everything is as expected.
Hi. The message in the assertFalse() statement only shows if the assert fails. So the message is designed to tell you what went wrong. In this case, if the file exists (because the assertFalse() failed), the message tells you that "File should not exist", so that is what is wrong. It is a little confusing. Good luck! Mark