Do you use assertions?

assert, assertions, java

Solution

I was taught to use lots of assertions back in the 90s and they made great sense. It's good defensive coding.

However, I think this has now been superceded by unit testing that actually forces the code to run and tells where it is broken. Debug asserts required someone to actually be running debug code and looking at the ui or logs. Unit testing can automate this.

Problem

This is not really a "question" so I'm making it CW. The ``` assert ``` Keyword is great! It should make, feel your self more confident with the code you wrote, but, until today when I was creating a small test class ( < 20 lines ) I realize a never use it since it was introduced. Heck! I barely use logger which is very useful indeed, but it wasn't until today I realize I don't use assertions. Do you use assertions? If no, what's the reason?

Original source