Menu

Introducing Persistence: Lesson 3 question

Dan P
2009-06-08
2013-04-09
  • Dan P

    Dan P - 2009-06-08

    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.

     
    • Mark Dexter

      Mark Dexter - 2009-06-08

      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

       

Log in to post a comment.