I don't like the java assert
keyword, because it is not always enabled in production code. I am looking for a good "ProductionAssert" class to use, that always runs the noted assertions.
One candidate is Guava's Preconditions. It's decent, but a bit limited (e.g. no assertEquals()
, assertNull()
, assertGreaterEquals()
).
One alternative is including jUnit or another test framework ... but I'm reluctant to depend upon an entire testing framework just for a simple assert class.
If I were programming in Groovy, I would use PowerAssert.
Is there a good "ProductionAssert" class for Java?
P.S. - one option is to finally check out something like Java Contracts ... but what I'm looking for right now it the absolute minimal, zero friction, just drop-it-in without any changes in the build process kind of class ... I'm not sure contracts fits that description.