Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2005

Tip: Looking for answers? Try searching our database.

what is assertion in java?

Thread view: 
SOAP - 25 Apr 2005 06:31 GMT
what is assertion in java?
thank you

               ~ ªÑ²¼»ù®æ¦³¤É¦³¶^, ¶R½æ­n¯à©Ó¾á­·ÀI ~

    ~ Samba, more than a low cost File and Printer server ~
           
                    -- Let us OpenSource --
Hal Rosser - 28 Apr 2005 04:44 GMT
> what is assertion in java?
> thank you

verifying correct preconditions and post conditions for your methods so
testing your software will go more smoothly
Jan =?ISO-8859-1?Q?Thom=E4?= - 05 Jun 2005 20:27 GMT
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.

best regards,
jan

>> what is assertion in java?
>> thank you
>>
> verifying correct preconditions and post conditions for your methods so
> testing your software will go more smoothly

Signature

______________________________________
insOMnia - We never sleep....
http://www.insomnia-hq.de

Raymond DeCampo - 05 Jun 2005 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

Signature

XML is the programmer's duct tape.

Jesper Matthiesen - 30 Jul 2005 07:48 GMT
... and a -assertion option can be specified to the compiler. If absent, the
assertions are ignored.
There's a good article here:
http://www.javaworld.com/javaworld/jw-11-2001/jw-1109-assert.html
/Jesper

>> what is assertion in java?
>> thank you
>>
> verifying correct preconditions and post conditions for your methods so
> testing your software will go more smoothly
Glen Pepicelli - 04 May 2005 23:50 GMT
The point is to verify your software is in a valid state.

For example if you KNOW the x should be greater than Y then you let your
program in on that knowledge:

assert ( x > Y)

This way if somehow y is greater than x your program tells you:

arrestion failed (x > y) line 4414.

> what is assertion in java?
> thank you
[quoted text clipped - 4 lines]
>            
>                      -- Let us OpenSource --


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.