/ Published in: Java

I was refactoring code lately, changed a method to return null instead of throwing an error - yet this test kept working. I did not get why for quite some time.
Lesson learned: Never rely on Eclipse generating a try-catch-block without actually looking what kind of exception or error it catches.
Lesson learned: Never rely on Eclipse generating a try-catch-block without actually looking what kind of exception or error it catches.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public void testShouldNotFindAfterDeletion(){ manager.createContact(contact); manager.deleteContact(contact.getID()); /* now try to read it again to make sure the delete request works: */ try { manager.getContact(contact.getID()); //this throws an AssertionError. fail("Should not reach this step, should throw exception first"); //mistake that should have been obvious: This also does. } catch (AssertionError e){ //succeed }; }
Comments
