Tuesday, January 17, 2017

How to use Assertion in Java Code - When, Where

Where and when to use Assertion in Java is probably the most important thing you want to know about Assertions. In last couple of articles we have seen What is Assertion in Java and How to enable or disable Assertion in Java while in this article we will discuss most important part “Where to use Java Assertions” as I have always said Java Assertion should be taken as replacement of JUnit testing or Exception in Java Instead Assertion compliments both Unit testing and Exception and if used property provides you another testing tool which may test application with more real data than JUnit tests.

Monday, January 16, 2017

How to enable or disable Assertion in Java

The good thing about Assertion in Java is that you can enable or disable Assertion at runtime. The designer of java are really very thoughtful, they have thought of many situations while designing java and its API. one of the gems is the ability to enable or disable assertion in runtime without any change on code. In last article we see how Assertion works in Java and now we will see some step by step guide on how to disable or enable Assertion in Java By default assertions in Java are disabled at runtime and JVM provides following options to deal with assertion in Java :