473,241 Members | 3,147 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,241 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 20223

"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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.