AFAIK, there are three common types of Asserts people use in Java viz.,
- http://docs.oracle.com/javase/1.4.2/docs/guide/lang/assert.html
- http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/util/Assert.html
- http://junit.sourceforge.net/javadoc/org/junit/Assert.html
Can you tell me the correct usage for each of the paradigm?
Options 1 and 2 are runtime assertions. They are usually used to make sure that you are getting only values that you expect to get.
Option 1 is more common since it’s a Java language feature. If you type
assertinto your code in an IDE, it will highlight it because it is a Java keyword (not part of the Jakarta library).Option 2 is Spring-specific; looking at the docs that you linked to, it says that following:
Option 3 is used almost exclusively for jUnit testing. They ensure that your tests are outputting the values that you expect your code to produce.
Most likely, you will use Option 1 in the code that you write. As the docs say, you probably will never use Option 2. You will only use Option 3 if you write jUnit tests.