Re: what is assertion in java?
- From: Raymond DeCampo <nospam@xxxxxxxxxxxx>
- Date: Sun, 05 Jun 2005 20:21:21 GMT
Jan Thomä wrote:
well the drawback of this is having your code cluttered with asserts all over the place. it is possibly better to have a testing framework (like junit) in place.
JUnit and asserts are not exactly equivalent technologies. How can you write a JUnit test that ensures that a particular method is never called with a null value? (Certainly not in any way that JUnit is typically used.)
Having code with asserts can be very helpful, as it is self documenting. If you see a method that takes a parameter x and you see an assert that x is not null, you know that the caller is responsible for not passing null values to the method. Asserts lay out the assumptions made by the code that follows.
Ray
-- XML is the programmer's duct tape. .
- References:
- Re: what is assertion in java?
- From: Jan Thomä
- Re: what is assertion in java?
- Prev by Date: Re: Old Java JDK !!!
- Next by Date: Re: what is assertion in java?
- Previous by thread: Re: what is assertion in java?
- Next by thread: Re: enums
- Index(es):
Relevant Pages
|