This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

howto test "assert" in eclipse ?  RSS feed

 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alvin chew
Ranch Hand
Posts: 834
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you , tim
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!