Execution will never reach this point

@sun: Programming With Assertions

assert false : "Execution should never reach this point!";

I was writing unit tests and came upon this document. I have been looking for a tutorial on assertions before and now I find out there is one right at sun. I should have known.

So far it looks good to me. I have had enough bugs that came from “should never happen” and not always did I put a comment there that told me I assumed that “this would never happen”.

So assertions make sense to keep track of the developer’s assumptions about what he is doing and when one of his assumptions was wrong at least he will know at once what is broken.

I’ll test the use of assertions and write some more 🙂

edit turning on the use of assertions with eclipse is non-trivial. The eclipse faq is helpful to get it done. If it still not works after that check wether your actual project settings are changed 😉 (and not only the workspace settings)

By Yashima

Writer of code and stories

1 comment

Comments are closed.