Thanks very much for your excellent video tutorials absolute beginner and introducing persistence!
Yesterday morning I had barely seen any java code, and tonight I'm filled with enough enthusiasm and knowledge to go off and write my own java project. I thought overall that the tutorials were excellent. I particularly like how everything was done in real-time (though I did have to pause a lot due to the fact that you were a lot more familiar with shortcuts etc. than myself).
Also, I believe I spotted a very small error. I'm not sure if this has been pointed out before.
In lesson 12 of the total beginner tutorial, you have the following lines:
assertTrue("Book did not check out correctly", ml.checkOut(b1, p1));
assertEquals("Fred", b1.getPerson().getName());
// make sure it fails if a book is already checked out
assertFalse("Book was already checked out", ml.checkOut(b1,p2));
assertTrue("Book check in failed", ml.checkIn(b1));
assertFalse("Book was already checked in", ml.checkIn(b1));
assertFalse("Book was never checked out", ml.checkIn(b2));
If you look carefully, the error message for when the initial assertFalse FAILS ["Book was already checked out"], is in fact the text corresponding to when the assertFalse succeeds. Instead the first line after the comment should read:
assertFalse("Book should have failed to check out", ml.checkOut(b1,p2));
The same applies for both the other two assertFalse statements, so the block should read:
assertTrue("Book did not check out correctly", ml.checkOut(b1, p1));
assertEquals("Fred", b1.getPerson().getName());
// make sure it fails if a book is already checked out
assertFalse("Book was already checked out", ml.checkOut(b1,p2));
assertTrue("Book check in failed", ml.checkIn(b1));
assertFalse("Book should not have checked in as it was not checked out", ml.checkIn(b1));
assertFalse("Book should not have checked in as it was never checked out", ml.checkIn(b2));
I was unsure at first whether the syntax may be different with the assertTrue than the assertFalse, but when you use the assertFalse later on in the tutorial you use it correctly (I think).
Anyway, thanks again for these tutorials. They have been really valuable - I'm definitely going to check out the workbench one tomorrow.
Suggestion for your next tutorial: User Interface Design & Implementation.
- redders.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's perverse, but correct as written. (I came here with a similar thought as you - ready to point out the error. However, when I wrote out my analysis, I realized I wasn't thinking about it clearly.)
The logic is as follows:
All tests should "succeed".
The mouse-over help tip for both asserts say that the message prints if the opposite of what you expect occurs. Pervese. ;-) assertTrue prints when the condition is false, and assertFalse prints when the condition is true. How droll!
In the case of the
assertTrue("Book did not checkout correctly", ml.checkOut(b1, p1));
a successful test means the
m1.checkOut
succeeded (because the book has not been checked out prior to this method call), returning TRUE, and that the message should not be printed.
Mark,
Thanks very much for your excellent video tutorials absolute beginner and introducing persistence!
Yesterday morning I had barely seen any java code, and tonight I'm filled with enough enthusiasm and knowledge to go off and write my own java project. I thought overall that the tutorials were excellent. I particularly like how everything was done in real-time (though I did have to pause a lot due to the fact that you were a lot more familiar with shortcuts etc. than myself).
Also, I believe I spotted a very small error. I'm not sure if this has been pointed out before.
In lesson 12 of the total beginner tutorial, you have the following lines:
assertTrue("Book did not check out correctly", ml.checkOut(b1, p1));
assertEquals("Fred", b1.getPerson().getName());
// make sure it fails if a book is already checked out
assertFalse("Book was already checked out", ml.checkOut(b1,p2));
assertTrue("Book check in failed", ml.checkIn(b1));
assertFalse("Book was already checked in", ml.checkIn(b1));
assertFalse("Book was never checked out", ml.checkIn(b2));
If you look carefully, the error message for when the initial assertFalse FAILS ["Book was already checked out"], is in fact the text corresponding to when the assertFalse succeeds. Instead the first line after the comment should read:
assertFalse("Book should have failed to check out", ml.checkOut(b1,p2));
The same applies for both the other two assertFalse statements, so the block should read:
assertTrue("Book did not check out correctly", ml.checkOut(b1, p1));
assertEquals("Fred", b1.getPerson().getName());
// make sure it fails if a book is already checked out
assertFalse("Book was already checked out", ml.checkOut(b1,p2));
assertTrue("Book check in failed", ml.checkIn(b1));
assertFalse("Book should not have checked in as it was not checked out", ml.checkIn(b1));
assertFalse("Book should not have checked in as it was never checked out", ml.checkIn(b2));
I was unsure at first whether the syntax may be different with the assertTrue than the assertFalse, but when you use the assertFalse later on in the tutorial you use it correctly (I think).
Anyway, thanks again for these tutorials. They have been really valuable - I'm definitely going to check out the workbench one tomorrow.
Suggestion for your next tutorial: User Interface Design & Implementation.
- redders.
It's perverse, but correct as written. (I came here with a similar thought as you - ready to point out the error. However, when I wrote out my analysis, I realized I wasn't thinking about it clearly.)
The logic is as follows:
All tests should "succeed".
The mouse-over help tip for both asserts say that the message prints if the opposite of what you expect occurs. Pervese. ;-) assertTrue prints when the condition is false, and assertFalse prints when the condition is true. How droll!
In the case of the
a successful test means the
succeeded (because the book has not been checked out prior to this method call), returning TRUE, and that the message should not be printed.
a successful test means that the
FAILED (because we're hoping the book is already checked out prior to this method call), therefore returning a FALSE, and a message should be printed.
It might have been clearer (to me and you at least) if he'd used the same assert in both cases, and instead did something like:
assertTrue("This should have worked but didn't: The book did not check out.", ml.checkOut(b1, p1));
assertTrue("This SHOULDN'T have worked but did: The book checked out twice.", ml.checkOut(b1, p2));
Or, if you want messages on success, rather than quiet…
assertFalse("Book check out succeeded.", ml.checkOut(b1, p1));
assertFalse("Prevention of multiple check out succeeded.", ml.checkOut(b1, p2));
I think… ;-) Don't quote me on my interpretation. I'm almost a Total Beginner. ;-)
Oops. Never mind. I'm still not thinking it through clearly. ;-)
Let me try that again… THIS would have made more sense to me:
assertTrue("Fail: This should have worked but didn't: The book did not check out.", ml.checkOut(b1, p1));
assertFalse("Fail: This SHOULDN'T have worked but did: The book checked out twice.", ml.checkOut(b1, p2));
Or, if you want messages on success, rather than quiet…
assertFalse("Success: Book check out succeeded.", ml.checkOut(b1, p1));
assertTrue("Success: Prevention of multiple check out succeeded.", ml.checkOut(b1, p2));
and I'll shut up now, in case I've still munged it. ;-)