File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes IDEs, Version Control and other tools and the fly likes howto test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "howto test "assert"  in eclipse ?" Watch "howto test "assert"  in eclipse ?" New topic

howto test "assert" in eclipse ?

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, good day , do anyone know how to test the assert function on eclipse IDE ?

let say i hv following code to test how assert to work

when i run the IDE , give me the error like "assert should not use for identifier" and also "the method assert(boolean) is undefined" ...anyone can guide how i test it ? thank you
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

You have to set the project up for J2SDK 1.4 or greater. The default is 1.3, which predates the addition of assertions.

If you select the project properties dialog, click on the "Java Compiler" topic and then select the "Compiler compliance" tab, you'll see options. You need to pick 1.4 or greater for both source and class file compatibility.

Note that this doesn't affect Ant Scripts, where you have to add the 'source="1.4"' option on the javac task or the interactive Java compiler in Eclipse will handle asserts properly (assuming you did the above) but batch compiles using your Ant file (if present) won't.

An IDE is no substitute for an Intelligent Developer.
Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
thank you , tim
I agree. Here's the link:
subject: howto test "assert" in eclipse ?
It's not a secret anymore!