This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 15639

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
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 ?
Similar Threads
Assert stmt in Eclipse
Converting int to string W/OUT toString, etc.
anonymous class example
Java Rule Round-Up
substring like function on BigDecimal/int datatype