473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

what is assertion in java?

what is assertion in java?
thank you
~ 股票價格有升有跌, 買賣*n能承擔*滅I ~

~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --
Jul 18 '05 #1
5 20229

"SOAP" <s@soap.com> wrote in message news:42********@usenet.hk...
what is assertion in java?
thank you

verifying correct preconditions and post conditions for your methods so
testing your software will go more smoothly
Jul 18 '05 #2

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.

SOAP wrote:
what is assertion in java?
thank you
~ 股票價格有升有跌, 買賣*n能承擔*滅I ~

~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --


Jul 18 '05 #3
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

Hal Rosser wrote:

"SOAP" <s@soap.com> wrote in message news:42********@usenet.hk...
what is assertion in java?
thank you

verifying correct preconditions and post conditions for your methods so
testing your software will go more smoothly


--
______________________________________
insOMnia - We never sleep....
http://www.insomnia-hq.de
Jul 18 '05 #4
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.
Jul 18 '05 #5
.... 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/j...09-assert.html
/Jesper

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:nY****************@bignews6.bellsouth.net...

"SOAP" <s@soap.com> wrote in message news:42********@usenet.hk...
what is assertion in java?
thank you

verifying correct preconditions and post conditions for your methods so
testing your software will go more smoothly

Jul 30 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
6
by: Cormac | last post by:
Hi everyone, I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and Windows2000. I'm running motions sensor hardware so there's a bit of real time data processing involved. When...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
1
by: Timur Safin | last post by:
Hi All, Sorry if it is offtopic here, I wasn't able to find any more relevant group... I'm slowly approaching AMD64 build for our product (as my personal fun project). And after I ran that...
6
by: Bhachi | last post by:
Briefly I will explain the build scenario. An utility "idlGen" is created by compiling a set of C++ files. This utility(exe) is used to generate some idl files from some application(A1) code....
669
by: Xah Lee | last post by:
in March, i posted a essay What is Expressiveness in a Computer Language, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Mullai | last post by:
Hi , My program gives an error message like this Debug Assertion Failed! program:................ File: wincore.cpp Line: 958 Please can anyone help me out in this issue. I have to solve...
3
by: ravit | last post by:
Hello All, I am trying to execute an application that is developed using eclipse libraries. Jface, SWT , etc. While I execute the application , i have received an exception which I am unable...
25
by: Cromulent | last post by:
On 2008-07-06 21:09:55 +0100, Joe Wright <joewwright@comcast.netsaid: Err, no not really as that has nothing to do with stock market prices :). -- "I disapprove of what you say, but I'll defend...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.